Przeglądaj źródła

meta: use a single `.env` file for config (#3498)

Fixes: https://github.com/transloadit/uppy/issues/3473
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Antoine du Hamel 3 lat temu
rodzic
commit
f4f1b810b7

+ 1 - 1
.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
 

+ 3 - 3
.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 <https://developers.facebook.com/apps>
 
-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"

+ 1 - 1
.gitignore

@@ -13,7 +13,7 @@ node_modules
 .yarn/install-state.gz
 yarn-error.log
 
-*.local
+.env
 
 dist/
 lib/

+ 2 - 6
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" \

+ 1 - 0
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",

+ 1 - 1
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,

+ 1 - 1
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

+ 3 - 3
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 <https://developers.facebook.com/apps>
 
-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"

+ 8 - 0
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"