From 684f04e39523558ccf78d8cface852330270194e Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 24 May 2022 14:21:22 +0300 Subject: [PATCH 1/4] add upgrade guide for 1.3.0 --- .../advanced/backend/upgrade-guides/1-3-0.md | 43 +++++++++++++++++++ www/docs/sidebars.js | 5 +++ 2 files changed, 48 insertions(+) create mode 100644 docs/content/advanced/backend/upgrade-guides/1-3-0.md diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-0.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md new file mode 100644 index 0000000000..b6e9ec06b4 --- /dev/null +++ b/docs/content/advanced/backend/upgrade-guides/1-3-0.md @@ -0,0 +1,43 @@ +# v1.3.0 + +Version 1.3.0 of Medusa introduces new features to Medusa as well as prepares for a more important update to version 1.3.1. + +This version introduces a change in loading environment variables into your Medusa server. + +## Environment Variables + +In previous versions of Medusa, The server automatically loads all environment variables in the `.env` file at the root of the Medusa server. + +This new update removes loading it automatically and gives developers the freedom in how to load their environment variables. All environment variables will be loaded by default from the system’s environment variables. + +### Actions Required + +If you use a `.env` file to load environment variables on your server, you need to load the variables manually in `medusa-config.js`. + +You can add the following code snippet at the top of the file which uses the [dotenv](https://www.npmjs.com/package/dotenv) package to load the environment variables based on the current Node environment: + +```jsx +const dotenv = require('dotenv') + + let ENV_FILE_NAME = ''; + switch (process.env.NODE_ENV) { + case 'production': + ENV_FILE_NAME = '.env.production'; + break; + case 'staging': + ENV_FILE_NAME = '.env.staging'; + break; + case 'test': + ENV_FILE_NAME = '.env.test'; + break; + case 'development': + default: + ENV_FILE_NAME = '.env'; + break; + } + + try { + dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME }); + } catch (e) { + } +``` diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 7ede695603..210c426713 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -214,6 +214,11 @@ module.exports = { label: 'Upgrade Guides', collapsed: true, items: [ + { + type: "doc", + id: "advanced/backend/upgrade-guides/1-3-0", + label: "v1.3.0" + }, { type: "doc", id: "advanced/backend/upgrade-guides/1-3-1", From a20261b3197356dca937a237a68b3dcd9add28c8 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 Jun 2022 14:15:17 +0300 Subject: [PATCH 2/4] Update 1-3-0.md --- docs/content/advanced/backend/upgrade-guides/1-3-0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-0.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md index b6e9ec06b4..769e3312e9 100644 --- a/docs/content/advanced/backend/upgrade-guides/1-3-0.md +++ b/docs/content/advanced/backend/upgrade-guides/1-3-0.md @@ -1,6 +1,6 @@ # v1.3.0 -Version 1.3.0 of Medusa introduces new features to Medusa as well as prepares for a more important update to version 1.3.1. +Version 1.3.0 of Medusa introduces new features and enhancements to Medusa's core. This version introduces a change in loading environment variables into your Medusa server. From b75867b119f5d49ef927131f3a0201879d8686b7 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 Jun 2022 19:16:26 +0300 Subject: [PATCH 3/4] merge 1.3.0 with 1.3.1 --- .../advanced/backend/upgrade-guides/1-3-0.md | 43 ------------------- .../advanced/backend/upgrade-guides/1-3-1.md | 40 ++++++++++++++++- www/docs/sidebars.js | 5 --- 3 files changed, 39 insertions(+), 49 deletions(-) delete mode 100644 docs/content/advanced/backend/upgrade-guides/1-3-0.md diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-0.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md deleted file mode 100644 index 769e3312e9..0000000000 --- a/docs/content/advanced/backend/upgrade-guides/1-3-0.md +++ /dev/null @@ -1,43 +0,0 @@ -# v1.3.0 - -Version 1.3.0 of Medusa introduces new features and enhancements to Medusa's core. - -This version introduces a change in loading environment variables into your Medusa server. - -## Environment Variables - -In previous versions of Medusa, The server automatically loads all environment variables in the `.env` file at the root of the Medusa server. - -This new update removes loading it automatically and gives developers the freedom in how to load their environment variables. All environment variables will be loaded by default from the system’s environment variables. - -### Actions Required - -If you use a `.env` file to load environment variables on your server, you need to load the variables manually in `medusa-config.js`. - -You can add the following code snippet at the top of the file which uses the [dotenv](https://www.npmjs.com/package/dotenv) package to load the environment variables based on the current Node environment: - -```jsx -const dotenv = require('dotenv') - - let ENV_FILE_NAME = ''; - switch (process.env.NODE_ENV) { - case 'production': - ENV_FILE_NAME = '.env.production'; - break; - case 'staging': - ENV_FILE_NAME = '.env.staging'; - break; - case 'test': - ENV_FILE_NAME = '.env.test'; - break; - case 'development': - default: - ENV_FILE_NAME = '.env'; - break; - } - - try { - dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME }); - } catch (e) { - } -``` diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-1.md b/docs/content/advanced/backend/upgrade-guides/1-3-1.md index 818b0c6175..1bc901819d 100644 --- a/docs/content/advanced/backend/upgrade-guides/1-3-1.md +++ b/docs/content/advanced/backend/upgrade-guides/1-3-1.md @@ -1,6 +1,6 @@ # v1.3.1 -Version 1.3.1 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API. The changes do not affect the public APIs and require only running necessary data migrations. +Version 1.3.1 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API, as well as a change in loading environment variables into your Medusa server. The changes do not affect the public APIs and require only running necessary data migrations. ## Prerequisites @@ -16,6 +16,44 @@ TYPEORM_MIGRATIONS=./node_modules/@medusajs/medusa/dist/migrations/*.js These environment variables are used in the data migration scripts in this upgrade. Make sure to replace `` with your PostgreSQL database URL. +## Environment Variables + +In previous versions of Medusa, The server automatically loads all environment variables in the `.env` file at the root of the Medusa server. + +This new update removes loading it automatically and gives developers the freedom in how to load their environment variables. All environment variables will be loaded by default from the system’s environment variables. + +### Actions Required + +If you use a `.env` file to load environment variables on your server, you need to load the variables manually in `medusa-config.js`. + +You can add the following code snippet at the top of the file which uses the [dotenv](https://www.npmjs.com/package/dotenv) package to load the environment variables based on the current Node environment: + +```jsx +const dotenv = require('dotenv') + + let ENV_FILE_NAME = ''; + switch (process.env.NODE_ENV) { + case 'production': + ENV_FILE_NAME = '.env.production'; + break; + case 'staging': + ENV_FILE_NAME = '.env.staging'; + break; + case 'test': + ENV_FILE_NAME = '.env.test'; + break; + case 'development': + default: + ENV_FILE_NAME = '.env'; + break; + } + + try { + dotenv.config({ path: process.cwd() + '/' + ENV_FILE_NAME }); + } catch (e) { + } +``` + ## Line Item Adjustments This new version of Medusa allows store operators to adjust line items in an order or a swap which provides more customization capabilities. diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 210c426713..7ede695603 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -214,11 +214,6 @@ module.exports = { label: 'Upgrade Guides', collapsed: true, items: [ - { - type: "doc", - id: "advanced/backend/upgrade-guides/1-3-0", - label: "v1.3.0" - }, { type: "doc", id: "advanced/backend/upgrade-guides/1-3-1", From 239de7dfddd2ff96cc2f644f61f011c3712e2081 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Wed, 1 Jun 2022 19:20:25 +0300 Subject: [PATCH 4/4] rename to 1.3.0 --- .../advanced/backend/upgrade-guides/{1-3-1.md => 1-3-0.md} | 4 ++-- www/docs/sidebars.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename docs/content/advanced/backend/upgrade-guides/{1-3-1.md => 1-3-0.md} (98%) diff --git a/docs/content/advanced/backend/upgrade-guides/1-3-1.md b/docs/content/advanced/backend/upgrade-guides/1-3-0.md similarity index 98% rename from docs/content/advanced/backend/upgrade-guides/1-3-1.md rename to docs/content/advanced/backend/upgrade-guides/1-3-0.md index 1bc901819d..8c34f81a2b 100644 --- a/docs/content/advanced/backend/upgrade-guides/1-3-1.md +++ b/docs/content/advanced/backend/upgrade-guides/1-3-0.md @@ -1,6 +1,6 @@ -# v1.3.1 +# v1.3.0 -Version 1.3.1 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API, as well as a change in loading environment variables into your Medusa server. The changes do not affect the public APIs and require only running necessary data migrations. +Version 1.3.0 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API, as well as a change in loading environment variables into your Medusa server. The changes do not affect the public APIs and require only running necessary data migrations. ## Prerequisites diff --git a/www/docs/sidebars.js b/www/docs/sidebars.js index 7ede695603..7a6ac76f11 100644 --- a/www/docs/sidebars.js +++ b/www/docs/sidebars.js @@ -216,8 +216,8 @@ module.exports = { items: [ { type: "doc", - id: "advanced/backend/upgrade-guides/1-3-1", - label: "v1.3.1" + id: "advanced/backend/upgrade-guides/1-3-0", + label: "v1.3.0" }, ] },