diff --git a/.devcontainer/on-create.sh b/.devcontainer/on-create.sh index a66491ef7..fbd5351f2 100755 --- a/.devcontainer/on-create.sh +++ b/.devcontainer/on-create.sh @@ -9,10 +9,5 @@ npm install # Copy the env file cp .env.example .env -# Source the env file, export the variables -set -a -source .env -set +a - # Run the migrations -npm run -w @documenso/prisma prisma:migrate-dev +npm run prisma:migrate-dev diff --git a/README.md b/README.md index 2795d206d..f488b4a63 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ git clone https://github.com/documenso/documenso - NEXT_PRIVATE_SMTP_FROM_NAME - NEXT_PRIVATE_SMTP_FROM_ADDRESS -5. Create the database schema by running `npm run prisma:migrate-dev -w @documenso/prisma` +5. Create the database schema by running `npm run prisma:migrate-dev` 6. Run `npm run dev` root directory to start @@ -254,6 +254,22 @@ containers: - '::' ``` +### I can't see environment variables in my package scripts + +Wrap your package script with the `with:env` script like such: + +``` +npm run with:env -- npm run myscript +``` + +The same can be done when using `npx` for one of bin scripts: + +``` +npm run with:env -- npx myscript +``` + +This will load environment variables from your `.env` and `.env.local` files. + ## Repo Activity ![Repository Activity](https://repobeats.axiom.co/api/embed/622a2e9aa709696f7226304b5b7178a5741b3868.svg) diff --git a/package.json b/package.json index 9f77b4aa3..57fcb5998 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,12 @@ "commitlint": "commitlint --edit", "clean": "turbo run clean && rimraf node_modules", "d": "npm run dx && npm run dev", - "dx": "npm i && npm run dx:up && npm run prisma:migrate-dev -w @documenso/prisma", + "dx": "npm i && npm run dx:up && npm run prisma:migrate-dev", "dx:up": "docker compose -f docker/compose-services.yml up -d", - "dx:down": "docker compose -f docker/compose-services.yml down" + "dx:down": "docker compose -f docker/compose-services.yml down", + "prisma:migrate-dev": "npm run with:env -- npm run prisma:migrate-dev -w @documenso/prisma", + "prisma:migrate-deploy": "npm run with:env -- npm run prisma:migrate-deploy -w @documenso/prisma", + "with:env": "dotenv -e .env -e .env.local --" }, "engines": { "npm": ">=8.6.0", @@ -22,8 +25,8 @@ "devDependencies": { "@commitlint/cli": "^17.7.1", "@commitlint/config-conventional": "^17.7.0", - "dotenv": "^16.0.3", - "dotenv-cli": "^7.2.1", + "dotenv": "^16.3.1", + "dotenv-cli": "^7.3.0", "eslint": "^8.40.0", "eslint-config-custom": "*", "husky": "^8.0.0", diff --git a/packages/prisma/package.json b/packages/prisma/package.json index 1b12a18a4..efd494ed6 100644 --- a/packages/prisma/package.json +++ b/packages/prisma/package.json @@ -18,6 +18,8 @@ }, "dependencies": { "@prisma/client": "5.3.1", + "dotenv": "^16.3.1", + "dotenv-cli": "^7.3.0", "prisma": "5.3.1" }, "devDependencies": {