浏览代码

meta: consolidate ENV files and fix contributing guidelines (#3475)

And use `pull_request_target` event instead of `pull_request` to use secrets from forks.

Fixes: https://github.com/transloadit/uppy/issues/3473

Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Antoine du Hamel 3 年之前
父节点
当前提交
f08b71d48b
共有 8 个文件被更改,包括 34 次插入92 次删除
  1. 1 6
      .env.example
  2. 10 21
      .github/CONTRIBUTING.md
  3. 1 1
      .github/workflows/end-to-end.yml
  4. 0 1
      .gitignore
  5. 10 9
      bin/companion.sh
  6. 0 31
      bin/run-example.js
  7. 1 2
      package.json
  8. 11 21
      website/src/_template/contributing.md

+ 1 - 6
.env.example

@@ -1,4 +1,4 @@
-# Rename this file to `.env`
+# Clone this file to `.env.local` and edit the clone. Don't put secrets in the `.env` files.
 
 NODE_ENV=development
 
@@ -32,11 +32,6 @@ COMPANION_ZOOM_SECRET=***
 COMPANION_UNSPLASH_KEY=***
 COMPANION_UNSPLASH_SECRET=***
 
-# Transloadit keys can also be used in `e2e/clients`
-TRANSLOADIT_KEY=***
-TRANSLOADIT_TEMPLATE=***
-TRANSLOADIT_SERVICE_URL=https://api2.transloadit.com
-
 # Development environment
 # =======================
 

+ 10 - 21
.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` set up. If it doesn’t exist, copy and rename the `.env.local` file and populate (some) of the values. What values need to be populated depends on what tests you want to run.
+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 start the testing suite run:
 
@@ -60,12 +60,10 @@ 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.sh` 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.local` in the repo root:
 
-```bash
-export COMPANION_INSTAGRAM_KEY="Instagram App ID"
-export COMPANION_INSTAGRAM_SECRET="Instagram App Secret"
-```
+    COMPANION_INSTAGRAM_KEY="Instagram App ID"
+    COMPANION_INSTAGRAM_SECRET="Instagram App Secret"
 
 Run
 
@@ -80,18 +78,11 @@ append `/instagram/redirect` to it, such as:
 
 Add this full ngrok URL to `Valid OAuth Redirect URIs` under `Instagram Basic Display`.
 
-Edit `bin/companion` and change to your ngrok URI:
-
-```bash
-COMPANION_DOMAIN="e0c7de09808d.ngrok.io"
-COMPANION_PROTOCOL="https"
-```
-
-Edit `examples/dev/Dashboard.js`:
+Edit `.env.local` and change to your ngrok URI:
 
-```js
-const COMPANION_URL = 'https://e0c7de09808d.ngrok.io'
-```
+    COMPANION_DOMAIN="e0c7de09808d.ngrok.io"
+    COMPANION_PROTOCOL="https"
+    VITE_COMPANION_URL = 'https://e0c7de09808d.ngrok.io'
 
 Go to: Roles -> Roles -> Add Instagram testers -> Add your instagram account
 
@@ -113,15 +104,13 @@ open http://localhost:4000/examples/dashboard
 Also check the other examples:
 
 ```bash
-cd examples/EXAMPLENAME
-yarn install
-yarn start
+yarn workspace <example-name> start
 ```
 
 Releases are managed by GitHub Actions, here’s an overview of the process to release a new Uppy version:
 
 * Run `yarn release` on your local machine.
-* Follow the instructions and select what packages to release. **Warning:** skipping packages results in those changes being "lost", meaning they won't be picked up in the changelog automatically next release. Always try to release all.
+* Follow the instructions and select what packages to release. **Warning:** skipping packages results in those changes being “lost”, meaning they won’t be picked up in the changelog automatically next release. Always try to release all.
 * Before committing, check if the generated files look good.
 * When asked to edit the next CHANGELOG, only include changes related to the package(s) you selected for release.
 * Push to the Transloadit repository using the command given by the tool. Do not open a PR yourself, the GitHub Actions will create one and assign you to it.

+ 1 - 1
.github/workflows/end-to-end.yml

@@ -2,7 +2,7 @@ name: End-to-end tests
 on:
   push:
     branches: [ main ]
-  pull_request:
+  pull_request_target:
     # We want all branches so we configure types to be the GH default again
     types: [ opened, synchronize, reopened ]
 

+ 0 - 1
.gitignore

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

+ 10 - 9
bin/companion.sh

@@ -1,19 +1,20 @@
 #!/usr/bin/env bash
 
 # Load local env vars. In CI, these are injected.
-if [ -f .env ]; then
+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)
+  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
 else
   env \
-  COMPANION_DATADIR="./output" \
-  COMPANION_DOMAIN="localhost:3020" \
-  COMPANION_PROTOCOL="http" \
-  COMPANION_PORT=3020 \
-  COMPANION_CLIENT_ORIGINS="" \
-  COMPANION_SECRET="development" \
-  nodemon --watch packages/@uppy/companion/src --exec node ./packages/@uppy/companion/src/standalone/start-server.js
+    COMPANION_DATADIR="./output" \
+    COMPANION_DOMAIN="localhost:3020" \
+    COMPANION_PROTOCOL="http" \
+    COMPANION_PORT=3020 \
+    COMPANION_CLIENT_ORIGINS="" \
+    COMPANION_SECRET="development" \
+    nodemon --watch packages/@uppy/companion/src --exec node ./packages/@uppy/companion/src/standalone/start-server.js
 fi
+

+ 0 - 31
bin/run-example.js

@@ -1,31 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * Lerna installs all the example dependencies into the root `node_modules`.
- * To run the examples they need to have access to executables from npm dependencies in their $PATH.
- * If you run `npm start` in a dependency folder, the root `node_modules/.bin` is not in the $PATH.
- *
- * This proxy executable can be run from the repository root using `npm run example`, so the root
- * `node_modules/.bin` will be in the $PATH. It then runs `npm start` in the specific example folder,
- * which will inherit the $PATH, so the example has access to executables from npm dependencies in both
- * its own and in the root `node_modules`.
- */
-
-const path = require('path')
-const { execSync } = require('child_process')
-
-const exampleName = process.argv[2]
-
-if (!exampleName) {
-  console.error('Usage: npm run example "name-of-example"')
-  process.exit(1)
-}
-
-const exampleDir = path.join(__dirname, '../examples', exampleName)
-// eslint-disable-next-line import/no-dynamic-require
-const pkg = require(path.join(exampleDir, 'package.json'))
-if (pkg.scripts && pkg.scripts.build) {
-  execSync('npm run build', { cwd: exampleDir, stdio: 'inherit' })
-}
-
-execSync('npm start', { cwd: exampleDir, stdio: 'inherit' })

+ 1 - 2
package.json

@@ -133,7 +133,6 @@
     "contributors:save": "yarn node ./bin/update-contributors.mjs",
     "dev:with-companion": "npm-run-all --parallel start:companion dev",
     "dev": "yarn workspace @uppy-dev/dev dev",
-    "example": "yarn node bin/run-example",
     "lint:fix": "yarn run lint -- --fix",
     "lint:markdown": "remark -f -q . -i .remarkignore",
     "lint:staged": "lint-staged",
@@ -144,7 +143,7 @@
     "size": "echo 'JS Bundle mingz:' && cat ./packages/uppy/dist/uppy.min.js | gzip | wc -c && echo 'CSS Bundle mingz:' && cat ./packages/uppy/dist/uppy.min.css | gzip | wc -c",
     "start:companion": "bash bin/companion.sh",
     "start": "npm-run-all --parallel watch start:companion web:start",
-    "e2e": "npm-run-all --parallel watch:js:lib e2e:client start:companion e2e:cypress",
+    "e2e": "yarn build && npm-run-all --parallel watch:js:lib e2e:client start:companion e2e:cypress",
     "e2e:ci": "start-server-and-test 'npm-run-all --parallel e2e:client start:companion' '1234|3020' e2e:headless",
     "e2e:client": "yarn workspace e2e client:start",
     "e2e:cypress": "yarn workspace e2e cypress:open",

+ 11 - 21
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` set up. If it doesn’t exist, copy and rename the `.env.local` file and populate (some) of the values. What values need to be populated depends on what tests you want to run.
+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 start the testing suite run:
 
@@ -62,12 +62,10 @@ 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.sh` 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.local` in the repo root:
 
-```bash
-export COMPANION_INSTAGRAM_KEY="Instagram App ID"
-export COMPANION_INSTAGRAM_SECRET="Instagram App Secret"
-```
+    COMPANION_INSTAGRAM_KEY="Instagram App ID"
+    COMPANION_INSTAGRAM_SECRET="Instagram App Secret"
 
 Run
 
@@ -82,18 +80,11 @@ append `/instagram/redirect` to it, such as:
 
 Add this full ngrok URL to `Valid OAuth Redirect URIs` under `Instagram Basic Display`.
 
-Edit `bin/companion` and change to your ngrok URI:
-
-```bash
-COMPANION_DOMAIN="e0c7de09808d.ngrok.io"
-COMPANION_PROTOCOL="https"
-```
-
-Edit `examples/dev/Dashboard.js`:
+Edit `.env.local` and change to your ngrok URI:
 
-```js
-const COMPANION_URL = 'https://e0c7de09808d.ngrok.io'
-```
+    COMPANION_DOMAIN="e0c7de09808d.ngrok.io"
+    COMPANION_PROTOCOL="https"
+    VITE_COMPANION_URL = 'https://e0c7de09808d.ngrok.io'
 
 Go to: Roles -> Roles -> Add Instagram testers -> Add your instagram account
 
@@ -115,16 +106,15 @@ open http://localhost:4000/examples/dashboard
 Also check the other examples:
 
 ```bash
-cd examples/EXAMPLENAME
-yarn install
-yarn start
+yarn workspace <example-name> start
 ```
 
 Releases are managed by GitHub Actions, here’s an overview of the process to release a new Uppy version:
 
 * Run `yarn release` on your local machine.
-* Follow the instructions and select what packages to release.
+* Follow the instructions and select what packages to release. **Warning:** skipping packages results in those changes being “lost”, meaning they won’t be picked up in the changelog automatically next release. Always try to release all.
 * Before committing, check if the generated files look good.
+* When asked to edit the next CHANGELOG, only include changes related to the package(s) you selected for release.
 * Push to the Transloadit repository using the command given by the tool. Do not open a PR yourself, the GitHub Actions will create one and assign you to it.
 * Wait for all the GitHub Actions checks to pass. If one fails, try to figure out why. Do not go ahead without consulting the rest of the team.
 * Review the PR thoroughly, and if everything looks good to you, approve the PR. Do not merge it manually!