From f4f1b810b76939cdbd6ffa5f3ceb4ec510fa4f33 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 17 Feb 2022 15:47:15 +0100 Subject: [PATCH] meta: use a single `.env` file for config (#3498) Fixes: https://github.com/transloadit/uppy/issues/3473 Co-authored-by: Antoine du Hamel Co-authored-by: Mikael Finstad --- .env.example | 2 +- .github/CONTRIBUTING.md | 6 +++--- .gitignore | 2 +- bin/companion.sh | 8 ++------ package.json | 1 + private/dev/Dashboard.js | 2 +- private/dev/DragDrop.js | 2 +- website/src/_template/contributing.md | 6 +++--- yarn.lock | 8 ++++++++ 9 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.env.example b/.env.example index e49e4bed6..a3c3f3769 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -# Clone this file to `.env.local` and edit the clone. Don't put secrets in the `.env` files. +# Clone this file to `.env` and edit the clone. NODE_ENV=development diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2587cc161..365fe92e7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -42,7 +42,7 @@ yarn run test:unit We use [Cypress](cypress.io/) for our e2e test suite. Be sure to checkout “[Writing your first test](https://docs.cypress.io/guides/getting-started/writing-your-first-test#Add-a-test-file)” and the “[Introduction to Cypress](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Cypress-Can-Be-Simple-Sometimes)”. You should also be aware of the “[Best Practices](https://docs.cypress.io/guides/references/best-practices)”. -To get started make sure you have your `.env.local` set up. If it doesn’t exist, it will use the default value in the `.env` file which won’t work for most cases. Consider copy `.env` in a file named `.env.local` and the values relevant for the test(s) you are trying to run. +To get started make sure you have your `.env` set up. Copy the contents of `.env.example` to a file named `.env` and add the values relevant for the test(s) you are trying to run. To start the testing suite run: @@ -60,7 +60,7 @@ Even though facebook [allows using](https://developers.facebook.com/blog/post/20 Make sure that you are using a development facebook app at -Go to “Instagram Basic Display” and find `Instagram App ID` and `Instagram App Secret`. Put them in a file called `.env.local` in the repo root: +Go to “Instagram Basic Display” and find `Instagram App ID` and `Instagram App Secret`. Put them in a file called `.env` in the repo root: COMPANION_INSTAGRAM_KEY="Instagram App ID" COMPANION_INSTAGRAM_SECRET="Instagram App Secret" @@ -78,7 +78,7 @@ append `/instagram/redirect` to it, such as: Add this full ngrok URL to `Valid OAuth Redirect URIs` under `Instagram Basic Display`. -Edit `.env.local` and change to your ngrok URI: +Edit `.env` and change to your ngrok URI: COMPANION_DOMAIN="e0c7de09808d.ngrok.io" COMPANION_PROTOCOL="https" diff --git a/.gitignore b/.gitignore index e0d5a6b97..9a6c3b85f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ node_modules .yarn/install-state.gz yarn-error.log -*.local +.env dist/ lib/ diff --git a/bin/companion.sh b/bin/companion.sh index eb647ab17..43b9437a4 100644 --- a/bin/companion.sh +++ b/bin/companion.sh @@ -1,12 +1,8 @@ #!/usr/bin/env bash # Load local env vars. In CI, these are injected. -if [ -f .env.local ]; then - # https://gist.github.com/mihow/9c7f559807069a03e302605691f85572?permalink_comment_id=3625310#gistcomment-3625310 - set -a - source <(sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g" .env.local) - set +a - nodemon --watch packages/@uppy/companion/src --exec node ./packages/@uppy/companion/src/standalone/start-server.js +if [ -f .env ]; then + nodemon --watch packages/@uppy/companion/src --exec node -r dotenv/config ./packages/@uppy/companion/src/standalone/start-server.js else env \ COMPANION_DATADIR="./output" \ diff --git a/package.json b/package.json index e2d3b03db..77ffe8c41 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "core-js": "~3.19.3", "cssnano": "^5.0.6", "dedent": "^0.7.0", + "dotenv": "^16.0.0", "esbuild": "^0.14.1", "esbuild-plugin-babel": "^0.2.3", "eslint": "^8.0.0", diff --git a/private/dev/Dashboard.js b/private/dev/Dashboard.js index 5d5cb1e42..e20931757 100644 --- a/private/dev/Dashboard.js +++ b/private/dev/Dashboard.js @@ -25,7 +25,7 @@ import DropTarget from '@uppy/drop-target' import Audio from '@uppy/audio' /* eslint-enable import/no-extraneous-dependencies */ -// DEV CONFIG: create a .env.local file to customize those values. +// DEV CONFIG: create a .env file in the project root directory to customize those values. const { VITE_UPLOADER : UPLOADER, VITE_COMPANION_URL : COMPANION_URL, diff --git a/private/dev/DragDrop.js b/private/dev/DragDrop.js index 253d61a9e..3f3cf1b1d 100644 --- a/private/dev/DragDrop.js +++ b/private/dev/DragDrop.js @@ -6,7 +6,7 @@ import DragDrop from '@uppy/drag-drop' import ProgressBar from '@uppy/progress-bar' /* eslint-enable import/no-extraneous-dependencies */ -// DEV CONFIG: create a .env.local file to customize those values. +// DEV CONFIG: create a .env file in the project root directory to customize those values. const { VITE_TUS_ENDPOINT : TUS_ENDPOINT, } = import.meta.env diff --git a/website/src/_template/contributing.md b/website/src/_template/contributing.md index cebfab71c..b1a6c1667 100644 --- a/website/src/_template/contributing.md +++ b/website/src/_template/contributing.md @@ -44,7 +44,7 @@ yarn run test:unit We use [Cypress](cypress.io/) for our e2e test suite. Be sure to checkout “[Writing your first test](https://docs.cypress.io/guides/getting-started/writing-your-first-test#Add-a-test-file)” and the “[Introduction to Cypress](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Cypress-Can-Be-Simple-Sometimes)”. You should also be aware of the “[Best Practices](https://docs.cypress.io/guides/references/best-practices)”. -To get started make sure you have your `.env.local` set up. If it doesn’t exist, it will use the default value in the `.env` file which won’t work for most cases. Copy `.env` to a file named `.env.local` and add the values relevant for the test(s) you are trying to run. +To get started make sure you have your `.env` set up. Copy the contents of `.env.example` to a file named `.env` and add the values relevant for the test(s) you are trying to run. To start the testing suite run: @@ -62,7 +62,7 @@ Even though facebook [allows using](https://developers.facebook.com/blog/post/20 Make sure that you are using a development facebook app at -Go to “Instagram Basic Display” and find `Instagram App ID` and `Instagram App Secret`. Put them in a file called `.env.local` in the repo root: +Go to “Instagram Basic Display” and find `Instagram App ID` and `Instagram App Secret`. Put them in a file called `.env` in the repo root: COMPANION_INSTAGRAM_KEY="Instagram App ID" COMPANION_INSTAGRAM_SECRET="Instagram App Secret" @@ -80,7 +80,7 @@ append `/instagram/redirect` to it, such as: Add this full ngrok URL to `Valid OAuth Redirect URIs` under `Instagram Basic Display`. -Edit `.env.local` and change to your ngrok URI: +Edit `.env` and change to your ngrok URI: COMPANION_DOMAIN="e0c7de09808d.ngrok.io" COMPANION_PROTOCOL="https" diff --git a/yarn.lock b/yarn.lock index 58d211bf0..7cd4e8418 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8538,6 +8538,7 @@ __metadata: core-js: ~3.19.3 cssnano: ^5.0.6 dedent: ^0.7.0 + dotenv: ^16.0.0 esbuild: ^0.14.1 esbuild-plugin-babel: ^0.2.3 eslint: ^8.0.0 @@ -16869,6 +16870,13 @@ __metadata: languageName: node linkType: hard +"dotenv@npm:^16.0.0": + version: 16.0.0 + resolution: "dotenv@npm:16.0.0" + checksum: 664cebb51f0a9a1d1b930f51f0271e72e26d62feaecc9dc03df39453dd494b4e724809ca480fb3ec3213382b1ed3f791aaeb83569a137f9329ce58efd4853dbf + languageName: node + linkType: hard + "dotenv@npm:^7.0.0": version: 7.0.0 resolution: "dotenv@npm:7.0.0"