feat: added npm2yarn package (#1347)
This commit is contained in:
@@ -8,12 +8,16 @@ Starting a new e-commerce project just got easier, now with one command.
|
||||
|
||||
## Getting started with `create-medusa-app`
|
||||
|
||||
Use `create-medusa-app` with your preferred package manager:
|
||||
Use `create-medusa-app` with npx:
|
||||
|
||||
```bash
|
||||
npx create-medusa-app
|
||||
```
|
||||
|
||||
Or Yarn:
|
||||
|
||||
```bash
|
||||
yarn create medusa-app
|
||||
|
||||
npx create-medusa-app
|
||||
```
|
||||
|
||||
Behind the scenes, `create-medusa-app` is populating your database with some initial set of mock data, which helps to interact with Medusa setup intuitively straight away.
|
||||
|
||||
@@ -12,7 +12,7 @@ This is a guide for deploying Medusa Admin on Netlify. Netlify is a platform tha
|
||||
|
||||
Install Netlify CLI on your machine using npm:
|
||||
|
||||
```shell=
|
||||
```bash npm2yarn
|
||||
npm install netlify-cli -g
|
||||
```
|
||||
|
||||
@@ -20,7 +20,7 @@ npm install netlify-cli -g
|
||||
|
||||
Connect to your Netlify account from your terminal:
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
netlify login
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ The Netlify CLI is used to achieve this.
|
||||
|
||||
#### Create a new site
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
netlify init
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ The default build and deploy settings fit the needs of a Gatsby application, so
|
||||
|
||||
#### Add an environment variable
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
netlify env:set GATSBY_MEDUSA_BACKEND_URL "https://your-medusa-server.com"
|
||||
```
|
||||
|
||||
@@ -54,7 +54,7 @@ The above environment variable should point to your Medusa server.
|
||||
|
||||
Finally to deploy the admin, commit and push your changes to the repository connected in step 3.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Deploy Medusa Admin on Netlify"
|
||||
git push origin main
|
||||
|
||||
@@ -12,7 +12,7 @@ This is a guide for deploying our [Gatsby storefront starter](https://github.com
|
||||
|
||||
Install Netlify CLI on your machine using npm:
|
||||
|
||||
```shell=
|
||||
```bash npm2yarn
|
||||
npm install netlify-cli -g
|
||||
```
|
||||
|
||||
@@ -20,7 +20,7 @@ npm install netlify-cli -g
|
||||
|
||||
Connect to your Netlify account from your terminal:
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
netlify login
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ The Netlify CLI is used to achieve this.
|
||||
|
||||
#### Create a new site
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
netlify init
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ The default build and deploy settings fit the needs of a Gatsby application, so
|
||||
|
||||
#### Add an environment variable
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
netlify env:set GATSBY_MEDUSA_BACKEND_URL "https://your-medusa-server.com"
|
||||
```
|
||||
|
||||
@@ -54,7 +54,7 @@ The above environment variable should point to your Medusa server.
|
||||
|
||||
Finally to deploy the storefront, commit and push your changes to the repository connected in step 3.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Deploy Medusa Admin on Netlify"
|
||||
git push origin main
|
||||
|
||||
@@ -20,13 +20,13 @@ Install Heroku on your machine:
|
||||
|
||||
**Ubuntu**
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
sudo snap install --classic heroku
|
||||
```
|
||||
|
||||
**MacOS**
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
brew tap heroku/brew && brew install heroku
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ Download the appropriate installer for your Windows installation:
|
||||
|
||||
Connect to your Heroku account from your terminal:
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku login
|
||||
```
|
||||
|
||||
@@ -51,7 +51,7 @@ heroku login
|
||||
|
||||
In your **Medusa project directory** run the following commands to create an app on Heroku and add it as a remote origin.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku create medusa-test-app
|
||||
heroku git:remote -a medusa-test-app
|
||||
```
|
||||
@@ -66,7 +66,7 @@ Medusa requires a Postgres database and a Redis instance to work. These are adde
|
||||
|
||||
Add a Postgres addon to your Heroku app
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku addons:create heroku-postgresql:hobby-dev
|
||||
```
|
||||
|
||||
@@ -78,7 +78,7 @@ Add a Redis instance to your Heroku app
|
||||
|
||||
> The addon `redistogo:nano` is free, but Heroku requires you to add a payment method to proceed.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku addons:create redistogo:nano
|
||||
```
|
||||
|
||||
@@ -88,7 +88,7 @@ You can find more informations, plans and pricing about Redis To Go [here](https
|
||||
|
||||
Medusa requires a set of environment variables. From you project repository run the following commands:.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku config:set NODE_ENV=production
|
||||
heroku config:set JWT_SECRET=your-super-secret
|
||||
heroku config:set COOKIE_SECRET=your-super-secret-pt2
|
||||
@@ -99,7 +99,7 @@ heroku config:set NPM_CONFIG_PRODUCTION=false
|
||||
|
||||
Additionally, we need to set the buildpack to Node.js
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku buildpacks:set heroku/nodejs
|
||||
```
|
||||
|
||||
@@ -108,25 +108,25 @@ heroku buildpacks:set heroku/nodejs
|
||||
The library we use for connecting to Redis, does not allow usernames in the connection string. Therefore, we need to perform the following commands to remove it.
|
||||
Get the current Redis URL:
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku config:get REDISTOGO_URL
|
||||
```
|
||||
|
||||
You should get something like:
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
redis://redistogo:some_password_123@some.redistogo.com:9660/
|
||||
```
|
||||
|
||||
Remove the username from the Redis URL:
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
redis://r̶e̶d̶i̶s̶t̶o̶g̶o̶:some_password_123@sole.redistogo.com:9660/
|
||||
```
|
||||
|
||||
Set the new environment variable `REDIS_URL`
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku config:set REDIS_URL=redis://:some_password_123@sole.redistogo.com:9660/
|
||||
```
|
||||
|
||||
@@ -138,7 +138,7 @@ Before jumping into the deployment, we need to configure Medusa.
|
||||
|
||||
Update `module.exports` to include the following:
|
||||
|
||||
```javascript=
|
||||
```js
|
||||
module.exports = {
|
||||
projectConfig: {
|
||||
redis_url: REDIS_URL,
|
||||
@@ -159,7 +159,7 @@ module.exports = {
|
||||
|
||||
Update `scripts` to include the following:
|
||||
|
||||
```json=
|
||||
```json
|
||||
...
|
||||
"scripts": {
|
||||
"serve": "medusa start",
|
||||
@@ -175,7 +175,7 @@ Update `scripts` to include the following:
|
||||
|
||||
Finally, we need to commit and push our changes to Heroku:
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Deploy Medusa App on Heroku"
|
||||
git push heroku HEAD:master
|
||||
@@ -185,7 +185,7 @@ git push heroku HEAD:master
|
||||
|
||||
You can explore your Heroku app build logs using the following command in your project directory.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku logs -n 500000 --remote heroku --tail
|
||||
```
|
||||
|
||||
@@ -193,7 +193,7 @@ heroku logs -n 500000 --remote heroku --tail
|
||||
|
||||
As an optional extra step, we can create a user for you to use when your admin system is up and running.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
heroku run -a medusa-test-app -- medusa user -e "some-user@test.com" -p "SuperSecret1234"
|
||||
```
|
||||
|
||||
|
||||
@@ -33,21 +33,21 @@ Our Medusa project needs a bit of configuration to fit the needs of Qovery.
|
||||
|
||||
First, add the Postgres and Redis database url to your `medusa-config.js`. In Qovery, click on your Medusa app in the environment overview. Navigate to environment variables in the sidebar on the left. Among the secret variables you should find your database urls. They should look something like this:
|
||||
|
||||
```javascript=
|
||||
```bash
|
||||
QOVERY_REDIS_123456789_DATABASE_URL
|
||||
QOVERY_POSTGRESQL_123456789_DATABASE_URL
|
||||
```
|
||||
|
||||
Add these to your `medusa-config.js`.
|
||||
|
||||
```javascript=
|
||||
```js
|
||||
const DATABASE_URL = process.env.QOVERY_POSTGRESQL_123456789_DATABASE_URL
|
||||
const REDIS_URL= process.env.QOVERY_REDIS_123456789_DATABASE_URL
|
||||
```
|
||||
|
||||
Furthermore, update `module.exports` to include the following:
|
||||
|
||||
```javascript=
|
||||
```js
|
||||
module.exports = {
|
||||
projectConfig: {
|
||||
redis_url: REDIS_URL,
|
||||
@@ -70,7 +70,7 @@ module.exports = {
|
||||
|
||||
We need to add a couple of more environment variables in Qovery. Add the following variables in your Console with an application scope:
|
||||
|
||||
```javascript=
|
||||
```bash
|
||||
JTW_SECRET=something_secret_jwt
|
||||
COOKIE_SECRET=something_secret_cookie
|
||||
```
|
||||
@@ -81,7 +81,7 @@ COOKIE_SECRET=something_secret_cookie
|
||||
|
||||
Update `scripts` to the following:
|
||||
|
||||
```json=
|
||||
```json
|
||||
"scripts": {
|
||||
"serve": "medusa start",
|
||||
"start": "medusa migrations run && medusa start",
|
||||
@@ -102,7 +102,7 @@ In your environment overview in Qovery, deploy your databases one after the othe
|
||||
|
||||
To initialise your first build Qovery, simply commit and push your changes.
|
||||
|
||||
```shell=
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "chore: Qovery setup"
|
||||
git push origin main
|
||||
|
||||
@@ -38,17 +38,20 @@ If you want to jump straight to the code for this series you can checkout:
|
||||
In order to get you started with your Gatsby, Contentful, Medusa store you must complete a couple of installations:
|
||||
|
||||
- Install the Medusa CLI
|
||||
|
||||
```bash npm2yarn
|
||||
npm install @medusajs/medusa-cli -g
|
||||
```
|
||||
yarn global add @medusajs/medusa-cli
|
||||
npm install -g @medusajs/medusa-cli
|
||||
```
|
||||
|
||||
- Install the Gatsby CLI
|
||||
|
||||
```bash npm2yarn
|
||||
npm install gatsby-cli -g
|
||||
```
|
||||
yarn global add gatsby-cli
|
||||
npm install -g gatsby-cli
|
||||
```
|
||||
|
||||
- [Create a Contentful account](https://www.contentful.com/sign-up/)
|
||||
- [Install Redis](https://redis.io/topics/quickstart)
|
||||
|
||||
```
|
||||
brew install redis
|
||||
brew services start redis
|
||||
@@ -60,7 +63,7 @@ Medusa has support for SQLite and PostgreSQL and uses Redis for caching and queu
|
||||
|
||||
We will make use of `medusa new` to setup your local Medusa server.
|
||||
|
||||
```sh
|
||||
```bash
|
||||
medusa new medusa-contentful-store https://github.com/medusajs/medusa-starter-contentful
|
||||
```
|
||||
|
||||
@@ -146,7 +149,14 @@ In the `/src` directory there are 4 special subdirectories that are added for yo
|
||||
|
||||
#### `/data`
|
||||
|
||||
We will be using two seed scripts to kickstart your development, namely `yarn seed:contentful` and `yarn seed`. Data for these seed scripts are contained in the `/data` directory.
|
||||
We will be using two seed scripts to kickstart your development, namely:
|
||||
|
||||
```bash npm2yarn
|
||||
npm run seed:contentful
|
||||
npm run seed
|
||||
```
|
||||
|
||||
Data for these seed scripts are contained in the `/data` directory.
|
||||
|
||||
When the seed scripts have been executed you will have a Contentful space that holds all the data for your website; this includes content for Pages, Navigtion Menu, etc.
|
||||
|
||||
@@ -229,8 +239,8 @@ Now that we have collected your credentials we are ready to migrate the Contentf
|
||||
|
||||
You can now run:
|
||||
|
||||
```shell
|
||||
yarn migrate:contentful
|
||||
```bash npm2yarn
|
||||
npm run migrate:contentful
|
||||
```
|
||||
|
||||
This script will run each of the migrations in the `contentful-migrations` directory. After it has completed navigate to your Contentful space and click "Content model" in the top navigation bar. You will see that the content types will be imported into your space. Feel free to familiarize yourself with the different types by clicking them and inspecting the different fields that they hold.
|
||||
@@ -239,8 +249,8 @@ This script will run each of the migrations in the `contentful-migrations` direc
|
||||
|
||||
The next step is to seed the Contentful space with some data that can be used to display your ecommerce store's pages and navigation. To seed the database open up your command line and run:
|
||||
|
||||
```shell
|
||||
yarn seed:contentful
|
||||
```bash npm2yarn
|
||||
npm run seed:contentful
|
||||
```
|
||||
|
||||
In your Contentful space navigate to "Content" and you will be able to see the different entries in your space. You can filter the entries by type to, for example, only view Pages:
|
||||
@@ -251,9 +261,9 @@ You will notice that there are not any Products in your store yet and this is be
|
||||
|
||||
To do this open your command line and run:
|
||||
|
||||
```shell
|
||||
yarn seed
|
||||
yarn start
|
||||
```bash npm2yarn
|
||||
npm run seed
|
||||
npm run start
|
||||
```
|
||||
|
||||
This will seed your Medusa database, which will result in `medusa-plugin-contentful` synchronizing data to your Contentful space. Everytime you add or update a product the data will be copied into your Contentful space for further enrichment.
|
||||
@@ -289,7 +299,11 @@ Once `gatsby new` is complete you should rename the `.env.template` file to `.en
|
||||
|
||||
To get your token go to **Settings** > **API Keys** > **Add API key**. Now click save and copy the token specified in the field "Content Delivery API - access token".
|
||||
|
||||
After you have copied the token and your space ID to your `.env`, you can run `yarn start` which will start your Gatsby development server on port 8000.
|
||||
After you have copied the token and your space ID to your `.env`, you can start your Gatsby development server on port 8000 by running:
|
||||
|
||||
```bash npm2yarn
|
||||
npm run start
|
||||
```
|
||||
|
||||
You can now go to https://localhost:8000 to check out your new Medusa store.
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ module.exports = function (migration, context) {
|
||||
|
||||
This small snippet will create a content model in your Contentful space with two fields: a title which will be used to name entries in a meaningful manner (i.e. it won't be displayed to customers) and a body which contains the rich text to display. To apply your migration run:
|
||||
|
||||
```shell
|
||||
yarn migrate:contentful --file contentful-migrations/rich-text.js
|
||||
```bash npm2yarn
|
||||
npm run migrate:contentful --file contentful-migrations/rich-text.js
|
||||
```
|
||||
|
||||
If you go to your Contentful space and click Content Model you will see that the Rich Text model has been added to your space:
|
||||
@@ -68,8 +68,8 @@ module.exports = function (migration, context) {
|
||||
|
||||
After migrating your space you are ready create your new contact page:
|
||||
|
||||
```shell
|
||||
yarn migrate:contentful --file contentful-migrations/update-page-module-validation.js
|
||||
```bash npm2yarn
|
||||
npm run migrate:contentful --file contentful-migrations/update-page-module-validation.js
|
||||
```
|
||||
|
||||
## Adding Rich Text to About
|
||||
@@ -197,8 +197,8 @@ module.exports = function (migration, context) {
|
||||
|
||||
Run the migration:
|
||||
|
||||
```
|
||||
yarn migrate:contentful --file contentful-migrations/product-add-modules.js
|
||||
```bash npm2yarn
|
||||
npm run migrate:contentful --file contentful-migrations/product-add-modules.js
|
||||
```
|
||||
|
||||
### Adding "Related Products" Tile Section
|
||||
|
||||
@@ -26,8 +26,8 @@ Navigate to users and perform the following steps:
|
||||
|
||||
First, install the plugin using your preferred package manager:
|
||||
|
||||
```
|
||||
yarn add medusa-file-minio
|
||||
```bash npm2yarn
|
||||
npm install medusa-file-minio
|
||||
```
|
||||
|
||||
Then configure your `medusa-config.js` to include the plugin alongside the required options:
|
||||
|
||||
@@ -51,8 +51,8 @@ Upon successful creation of the user, you are presented with an **Access key ID*
|
||||
|
||||
First, install the plugin using your preferred package manager:
|
||||
|
||||
```
|
||||
yarn add medusa-file-s3
|
||||
```bash npm2yarn
|
||||
npm install medusa-file-s3
|
||||
```
|
||||
|
||||
Then configure your `medusa-config.js` to include the plugin alongside the required options:
|
||||
|
||||
@@ -20,8 +20,8 @@ Navigate to API in the left sidebar. Generate a new Spaces access key. This shou
|
||||
|
||||
First, install the plugin using your preferred package manager:
|
||||
|
||||
```
|
||||
yarn add medusa-file-spaces
|
||||
```bash npm2yarn
|
||||
npm install medusa-file-spaces
|
||||
```
|
||||
|
||||
Then configure your `medusa-config.js` to include the plugin alongside the required options:
|
||||
|
||||
Reference in New Issue
Block a user