diff --git a/FAQ.md b/FAQ.md index b28fd919c57921de46a9a8dc3675dc87ff42ace2..ca59fd30bce45b576fe0206a874ee562247fd96e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -100,4 +100,4 @@ And then install the `pgcrypto` extension to the `kotahidev` database: kotahidev=# create extension pgcrypto; ``` -Migrate the test database using `yarn dotenv pubsweet migrate`. \ No newline at end of file +Migrate the test database using `yarn dotenv yarn pubsweet migrate`. diff --git a/README.md b/README.md index b4ba34194338cc0464ab0e958ae70159292ddde0..8f2c80f2b00ebe2f59fc909a7bfa2c0e57eaca20 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This will: If you're using `docker-compose` to stand up a PostgreSQL database, everything will already be configured and you only need to ``` -> yarn dotenv yarn test:chrome +> yarn test:chrome ``` This will load the test runner in your local environment and using the correct environment variables (set in your `.env` file). diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 92a3a481f3c6041a92249012d4901767a50a3a69..514280d0f7ade9cf7252dd241329dcbfa3b19169 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -11,11 +11,12 @@ // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) -const seed = require('../../scripts/clearAndSeed') - const { execSync } = require('child_process') const path = require('path') +require('dotenv').config({ path: path.join(__dirname, '../../.env') }) + const { readFileSync } = require('fs') +const seed = require('../../scripts/clearAndSeed') const dumpFile = name => path.join(__dirname, '..', 'dumps', `${name}.sql`) @@ -38,15 +39,18 @@ module.exports = (on, config) => { `pg_dump --column-inserts -d simplej > ${dumpFile(name)}`, ) } + return true }, restore: async name => seed(readFileSync(dumpFile(name), 'utf-8')), createToken: async name => { const { User } = require('@pubsweet/models') const authentication = require('pubsweet-server/src/authentication') + const user = await User.query() .where({ username: testUsers[name] }) .first() + return authentication.token.create(user) }, }) diff --git a/package.json b/package.json index d2fc73e7023538ae680a712509533dabf7800f3a..d02b5540f0dc75fc5732ad3d253023128eeaf921 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "formik": "^2.0.0", "prettier": "2.2.1", "prosemirror-gapcursor": "^1.1.3", - "prosemirror-model": "1.11.2" + "prosemirror-model": "1.11.2", + "pg": "8.4.0" }, "dependencies": { "@apollo/client": "3.2.2", diff --git a/server/app.js b/server/app.js index 58ac0761d92ccc8f651f21f9bc8061ac839f4bff..83a00c011b62ae0a3539052a706d6c4b0bec786e 100644 --- a/server/app.js +++ b/server/app.js @@ -2,7 +2,7 @@ // The global requires here are used to avoid cyclical dependencies // The param reassigns are intentional, used as a way to set Express routes const path = require('path') -require('dotenv').config() +require('dotenv').config({ path: path.join(__dirname, '../.env') }) const config = require('config') const express = require('express') diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js index 4b471dce06410316851ceb624abfabdd49150611..4a35e3b8bab4dbba988d515b568e2b1f48b90fd9 100644 --- a/webpack/webpack.config.js +++ b/webpack/webpack.config.js @@ -1,7 +1,7 @@ const path = require('path') const fs = require('fs-extra') const { pick } = require('lodash') -require('dotenv').config() +require('dotenv').config({ path: path.join(__dirname, '../.env') }) const config = require('config') const rules = require('./common-rules') diff --git a/yarn.lock b/yarn.lock index f7a5a83af14b503dea25efb08e768ceeb219a769..62ba5986cf605902af42217331824fa154bacbd2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17083,11 +17083,6 @@ pg-boss@^5.2.0: pg "^8.5.1" uuid "^8.3.2" -pg-connection-string@0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-0.1.3.tgz#da1847b20940e42ee1492beaf65d49d91b245df7" - integrity sha1-2hhHsglA5C7hSSvq9l1J2RskXfc= - pg-connection-string@2.4.0, pg-connection-string@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.4.0.tgz#c979922eb47832999a204da5dbe1ebf2341b6a10" @@ -17103,22 +17098,12 @@ pg-ipc@^1.0.4: resolved "https://registry.yarnpkg.com/pg-ipc/-/pg-ipc-1.0.5.tgz#9aad40e51a123c41b635f97748372578ddf8de94" integrity sha512-nF4uB5vuqvPCeyWGLRVCOLxGaXq8tVMVZ+rCkX0XGbErlUUCwpb6+uME6s6vkB2T3n8lhZwojn5frFl67I5Ugg== -pg-packet-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/pg-packet-stream/-/pg-packet-stream-1.1.0.tgz#e45c3ae678b901a2873af1e17b92d787962ef914" - integrity sha512-kRBH0tDIW/8lfnnOyTwKD23ygJ/kexQVXZs7gEyBljw4FYqimZFxnMMx50ndZ8In77QgfGuItS5LLclC2TtjYg== - -pg-pool@^2.0.10: - version "2.0.10" - resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-2.0.10.tgz#842ee23b04e86824ce9d786430f8365082d81c4a" - integrity sha512-qdwzY92bHf3nwzIUcj+zJ0Qo5lpG/YxchahxIN8+ZVmXqkahKXsnl2aiJPHLYN9o5mB/leG+Xh6XKxtP7e0sjg== - -pg-pool@^3.2.2: +pg-pool@^3.2.1: version "3.2.2" resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.2.2.tgz#a560e433443ed4ad946b84d774b3f22452694dff" integrity sha512-ORJoFxAlmmros8igi608iVEbQNNZlp89diFVx6yV5v+ehmpMY9sK6QgpmgoXbmkNaBAx8cOOZh9g80kJv1ooyA== -pg-protocol@^1.4.0: +pg-protocol@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.4.0.tgz#43a71a92f6fe3ac559952555aa3335c8cb4908be" integrity sha512-El+aXWcwG/8wuFICMQjM5ZSAm6OWiJicFdNYo+VY3QP+8vI4SvLIWVe51PppTzMhikUJR+PsyIFKqfdXPz/yxA== @@ -17134,30 +17119,16 @@ pg-types@^2.1.0: postgres-date "~1.0.4" postgres-interval "^1.1.0" -pg@^7.4.1, pg@^7.8.0: - version "7.18.2" - resolved "https://registry.yarnpkg.com/pg/-/pg-7.18.2.tgz#4e219f05a00aff4db6aab1ba02f28ffa4513b0bb" - integrity sha512-Mvt0dGYMwvEADNKy5PMQGlzPudKcKKzJds/VbOeZJpb6f/pI3mmoXX0JksPgI3l3JPP/2Apq7F36O63J7mgveA== - dependencies: - buffer-writer "2.0.0" - packet-reader "1.0.0" - pg-connection-string "0.1.3" - pg-packet-stream "^1.1.0" - pg-pool "^2.0.10" - pg-types "^2.1.0" - pgpass "1.x" - semver "4.3.2" - -pg@^8.5.1: - version "8.5.1" - resolved "https://registry.yarnpkg.com/pg/-/pg-8.5.1.tgz#34dcb15f6db4a29c702bf5031ef2e1e25a06a120" - integrity sha512-9wm3yX9lCfjvA98ybCyw2pADUivyNWT/yIP4ZcDVpMN0og70BUWYEGXPCTAQdGTAqnytfRADb7NERrY1qxhIqw== +pg@8.4.0, pg@^7.4.1, pg@^7.8.0, pg@^8.5.1: + version "8.4.0" + resolved "https://registry.yarnpkg.com/pg/-/pg-8.4.0.tgz#7c754e0b907e8dae3af6fff0a0014c77f1418842" + integrity sha512-01LcNrAf+mBI46c78mE86I5o5KkOM942lLiSBdiCfgHTR+oUNIjh1fKClWeoPNHJz2oXe/VUSqtk1vwAQYwWEg== dependencies: buffer-writer "2.0.0" packet-reader "1.0.0" pg-connection-string "^2.4.0" - pg-pool "^3.2.2" - pg-protocol "^1.4.0" + pg-pool "^3.2.1" + pg-protocol "^1.3.0" pg-types "^2.1.0" pgpass "1.x" @@ -19961,11 +19932,6 @@ semver-regex@^2.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.2.tgz#c7a07158a80bedd052355b770d82d6640f803be7" - integrity sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c= - semver@6.3.0, semver@^6.0.0, semver@^6.1.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"