docs: used the NPX CLI tool across docs (#4099)

This commit is contained in:
Shahed Nasser
2023-05-15 11:04:14 +03:00
committed by GitHub
parent 23a0c5b71e
commit 7da6cc961e
57 changed files with 74 additions and 68 deletions

View File

@@ -110,8 +110,8 @@ If you disabled the `serve` option, you need to run the admin dashboard separate
You can test the admin dashboard by running the following command in the directory of the Medusa backend:
```bash npm2yarn
npm run start
```bash
npx @medusajs/medusa-cli develop
```
This starts the Medusa Backend and the admin dashboard. By default, the admin will be available on the URL `localhost:9000/app`. If you set the `path` option, then the admin will be available on `localhost:9000/<PATH>` with `<PATH>` being the value of the `path` option.
@@ -208,7 +208,7 @@ Passwords in Medusa are hashed using the [scrypt-kdf](https://www.npmjs.com/pack
To create a new admin user from the command line, run the following command in the directory holding your Medusa backend:
```bash
medusa user -e some@email.com -p some-password
npx @medusajs/medusa-cli user -e some@email.com -p some-password
```
This will create a new user that you can use to log into your admin panel.

View File

@@ -128,7 +128,7 @@ This section explains how to deploy the admin using the Vercel website:
1. Open the [Vercel dashboard](https://vercel.com/dashboard) after logging in.
2. Click on the “Add New…” button next to the search bar.
3. Choose Project from the dropdown.
4. In the new page that opens, find the Git repository that holds your medusa backend and click on the Import button. If you havent connected your Vercel account to any Git provider, you must do that first.
4. In the new page that opens, find the Git repository that holds your Medusa backend and click on the Import button. If you havent connected your Vercel account to any Git provider, you must do that first.
5. In the Configure Project form:
1. Set the Framework Preset to Vite.
2. Open the Build and Output Settings collapsible, and set the Build Command to `yarn build:admin` and the Output Directory to `build`. If youve configured the admin to use a different output directory, then change it to that directory.

View File

@@ -152,7 +152,7 @@ If you havent added any products to your Medusa backend, the build process mi
Alternatively, you can seed the backend with demo data by running this command in the root directory of the backend:
```bash noReport
medusa seed -f data/seed.json
npx @medusajs/medusa-cli seed -f data/seed.json
```
:::
@@ -285,7 +285,7 @@ If you havent added any products to your Medusa backend, the build process mi
Alternatively, you can seed the backend with demo data by running this command in the root directory of the backend:
```bash noReport
medusa seed -f data/seed.json
npx @medusajs/medusa-cli seed -f data/seed.json
```
:::

View File

@@ -91,7 +91,7 @@ Where `test` is the name of the database schema that should be used instead of `
Remember to run migrations after you change your database type to `postgres` from another type:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
### Common Configuration

View File

@@ -272,7 +272,7 @@ class PublishStrategy extends AbstractBatchJobStrategy {
After you create the batch job and before testing it out, you must run the build command in the directory of your Medusa backend:
```bash
```bash npm2yarn
npm run build
```
@@ -283,7 +283,7 @@ npm run build
This section covers how to test and use your batch job strategy. Make sure to start your backend first:
```bash
npm run start
npx @medusajs/medusa-cli develop
```
:::info

View File

@@ -253,7 +253,7 @@ You can also add any necessary options to the module. The options added in the e
Then, to test the module, run the Medusa backend which also runs your module:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
---

View File

@@ -64,7 +64,7 @@ This registers the in-memory cache module as the main cache service to use. You
To test the module, run the following command to start the Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
The backend should then start with no errors, indicating that the module was installed successfully.

View File

@@ -82,7 +82,7 @@ Other available options include:
To test the module, run the following command to start the Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
If the module was installed successfully, you should see the following message in the logs:

View File

@@ -193,7 +193,7 @@ npm run build
Then, run your backend with the following command:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
If you try accessing the endpoints you added the middleware to, you should see your implementation working as expected.

View File

@@ -125,7 +125,7 @@ npm run build
Then, run the following command to start your backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
You should see your custom implementation working as expected.

View File

@@ -248,7 +248,7 @@ You can also add any necessary options to the module.
Then, to test the module, run the Medusa backend which also runs your module:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
---

View File

@@ -58,7 +58,7 @@ This registers the local events module as the main events service to use. This m
To test the module, run the following command to start the Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
If the module was installed successfully, you should see the following message in the logs:

View File

@@ -85,7 +85,7 @@ Other available options include:
To test the module, run the following command to start the Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
If the module was installed successfully, you should see the following message in the logs:

View File

@@ -59,7 +59,7 @@ For example, if the value of the environment variable is set to `false`, but the
As feature flags generally include adding new entities or making changes to entities in the database, you must run the migrations after enabling the feature flag:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
:::info

View File

@@ -397,7 +397,7 @@ This section explains how to test out your implementation if the file service wa
Run your backend to test it out:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Then, try uploading a file, for example, using the [Upload File endpoint](/api/admin#tag/Uploads/operation/PostUploads). The file should be uploaded based on the logic youve implemented.

View File

@@ -80,7 +80,7 @@ This section explains how to test out the loader if its created in the Medusa
Run the following command to start the Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Your loader script should run on the Medusa backend startup. If you logged a message in the console, similar to the example above, you should see it in the console.

View File

@@ -293,7 +293,7 @@ The `resources` property can have one of the following values:
Finally, to test your module, run the following command:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
This starts the Medusa backend and runs your module as part of it.

View File

@@ -297,13 +297,19 @@ Notice that the value of the `identifier` static property defined in the `EmailS
Make sure you have an event bus module configured in your Medusa backend. You can learn more on how to do that in the [Configurations guide](../backend/configurations.md).
Then, start by running your Medusa backend:
Then, run the build command in the root directory of your Medusa backend:
```bash npm2yarn
npm run start
npm run build
```
Then, place an order either using the [REST APIs](/api/store) or using the storefront.
Next, start your Medusa backend:
```bash npm2yarn
npx @medusajs/medusa-cli develop
```
Try now to place an order either using the [REST APIs](/api/store) or using the storefront.
:::tip

View File

@@ -146,7 +146,7 @@ npm run build
Then, run the following command to start your Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
If the scheduled job was registered successfully, you should see a message similar to this logged on your Medusa backend:

View File

@@ -403,7 +403,7 @@ This section explains how to test out your implementation if the search service
Run your backend to test it out:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
You can then send a request to the [Search Products endpoint](/api/store#tag/Products/operation/PostProductsSearch) to see if your search service returns any results.

View File

@@ -80,7 +80,7 @@ npm run build
Then, start the backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
You should see the customizations you made in effect.

View File

@@ -73,7 +73,7 @@ npm run build
Run your backend to test it out:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
You can test now whether your strategy is working by performing the actions that run your strategy.

View File

@@ -32,7 +32,7 @@ const medusa = new Medusa()
## How to Use this Reference
You'll find in the sidebar of this reference names of different resources. These resources are properties in the medusa instance you initialize and you can access them directly using the instance. Then, you'll be able to access the methods or nested resources within those resources.
You'll find in the sidebar of this reference names of different resources. These resources are properties in the Medusa instance you initialize and you can access them directly using the instance. Then, you'll be able to access the methods or nested resources within those resources.
For example, to create a new customer you can access the [create](/references/js-client/classes/CustomerResource#create) method under the [customers](/references/js-client/classes/CustomerResource) property of your client:

View File

@@ -88,7 +88,7 @@ You can also pass the following props to Medusa Provider:
### Queries
To fetch data from the Medusa backend (in other words, perform `GET` requests), you can use [Queries](https://tanstack.com/query/v4/docs/react/guides/queries). Query hooks simply wrap around Tanstack Query's `useQuery` hook to fetch data from your medusa backend.
To fetch data from the Medusa backend (in other words, perform `GET` requests), you can use [Queries](https://tanstack.com/query/v4/docs/react/guides/queries). Query hooks simply wrap around Tanstack Query's `useQuery` hook to fetch data from your Medusa backend.
For example, to fetch products from your Medusa backend:
@@ -133,7 +133,7 @@ You can learn more about using queries in [Tanstack Querys documentation](htt
### Mutations
To create, update, or delete data on the Medusa backend (in other words, perform `POST`, `PUT`, and `DELETE` requests), you can use [Mutations](https://tanstack.com/query/v4/docs/react/guides/mutations). Mutation hooks wrap around Tanstack Query's `useMutation` to mutate data on your medusa backend.
To create, update, or delete data on the Medusa backend (in other words, perform `POST`, `PUT`, and `DELETE` requests), you can use [Mutations](https://tanstack.com/query/v4/docs/react/guides/mutations). Mutation hooks wrap around Tanstack Query's `useMutation` to mutate data on your Medusa backend.
For example, to create a cart:
@@ -356,7 +356,7 @@ To facilitate building custom storefronts, `medusa-react` also exposes a `CartP
`CartProvider` makes use of some of the hooks already exposed by `medusa-react` to perform cart operations on the Medusa backend. You can use it to create a cart, start the checkout flow, authorize payment sessions, and so on.
It also manages one single global piece of state which represents a cart, exactly like the one created on your medusa backend.
It also manages one single global piece of state which represents a cart, exactly like the one created on your Medusa backend.
To use `CartProvider`, you first have to insert it somewhere in your component tree below the `MedusaProvider`.

View File

@@ -117,7 +117,7 @@ npm run build
Run your backend to test it out:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Then, try out your strategy using the Complete Cart endpoint. You should see the logic you implemented used for completing the cart.

View File

@@ -43,7 +43,7 @@ module.exports = {
Run the following command to reflect schema changes into your database:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
### Step 4: Run Migration Script
@@ -83,7 +83,7 @@ module.exports = {
Run the following command to reflect schema changes into your database:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
### Step 4: Run Migration Script

View File

@@ -566,7 +566,7 @@ It returns the Order Edit object. You can access the following properties relate
:::tip
💡 This request triggers the event `order-edit.requested`. You can use a subscriber to send an email to the customer with a link to view the order edit on the storefront. You can learn more in the [Events reference](../../../development/events/events-list.md).
This request triggers the event `order-edit.requested`. You can use a subscriber to send an email to the customer with a link to view the order edit on the storefront. You can learn more in the [Events reference](../../../development/events/events-list.md).
:::

View File

@@ -191,7 +191,7 @@ If `difference_due` is less than 0, then the amount will be refunded to the cust
:::note
💡 This section explains how to authorize the payment using one payment processor and payment session. However, payment collections allow customers to pay in installments or with more than one provider. You can learn more about how to do that using the [batch endpoints of the Payment APIs](/api/store/#tag/Payment/operation/PostPaymentCollectionsSessionsBatchAuthorize)
This section explains how to authorize the payment using one payment processor and payment session. However, payment collections allow customers to pay in installments or with more than one provider. You can learn more about how to do that using the [batch endpoints of the Payment APIs](/api/store/#tag/Payment/operation/PostPaymentCollectionsSessionsBatchAuthorize)
:::

View File

@@ -122,7 +122,7 @@ npm run build
Run your backend to test it out:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Then, try out your strategy using any of the [Products](/api/store/#tag/Product) or [Carts](/api/store/#tag/Cart) endpoints which include retrieving product variants and line items respectively. You should then see the prices in the response based on your implemented strategy.

View File

@@ -11,7 +11,7 @@ Products are items or services that businesses sell to their customers. This ove
:::note
💡 Not a developer? Check out the [Products user guide](../../user-guide/products/manage.mdx).
Not a developer? Check out the [Products user guide](../../user-guide/products/manage.mdx).
:::

View File

@@ -202,7 +202,7 @@ npm run build
Run your backend to test it out:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Before you can test out your tax provider, you must enable it in a region. You can do that either using the [Medusa Admin dashboard](../../../user-guide/taxes/manage.md#change-tax-provider) or using the [Update Region admin endpoint](../admin/manage-tax-settings.mdx#change-tax-provider-of-a-region).

View File

@@ -120,7 +120,7 @@ npm run build
Run your backend to test it out:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
To test it out, you can simulate a checkout flow and check the calculated taxes to see if it matches the logic you implemented in the `calculate` method.

View File

@@ -130,7 +130,7 @@ const plugins = [
Run your backend with the following command:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Then, try triggering one of the [mentioned events earlier in this document](#events-that-the-segment-plugin-tracks). For example, you can place an order either using the [REST APIs](https://docs.medusajs.com/api/store) or using the [Next.js starter storefront](../../starters/nextjs-medusa-starter.mdx).

View File

@@ -251,7 +251,7 @@ export const query = graphql`
To test this out, run your Medusa backend by running this command in its directory:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Then run the Gatsby storefront by running this command in its directory:

View File

@@ -167,7 +167,7 @@ npm run seed
To start the backend run the following command:
```bash
npm run start
npx @medusajs/medusa-cli develop
```
If you seeded the database with demo data, you should see that events related to the products are triggered.

View File

@@ -172,7 +172,7 @@ npm run develop
Then, in the directory of your Medusa backend, run the following command to start the Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Once you start your Medusa backend, if you ran the `--seed` command when you created your Medusa backend, youll see that `product.created` events have been triggered along with similar events. This will update Strapi with the products you seeded.

View File

@@ -177,7 +177,7 @@ If you have multiple storage plugins configured, the last plugin declared in the
Run your Medusa backend with the following command:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Then, you can either test the plugin using the [REST APIs](/api/store) or using the [Medusa Admin](../../admin/quickstart.mdx).

View File

@@ -137,7 +137,7 @@ If you have multiple storage plugins configured, the last plugin declared in the
Run your Medusa backend with the following command:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
Then, you can either test the plugin using the [REST APIs](/api/store) or using the [Medusa Admin](../../admin/quickstart.mdx).

View File

@@ -3962,7 +3962,7 @@ You can also optionally pass the option `localization` if you want to support di
Run your backend now:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
To test it out, perform an action that would trigger one of the emails being sent. For example, you can use your Medusa storefront to create an order. An email from your SendGrid account will be sent to the customer email.

View File

@@ -194,7 +194,7 @@ const plugins = [
Run your Medusa backend with the following command:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
The quickest way to test that the integration is working is by sending a `POST` request to `/store/products/search`. This endpoint accepts a `q` body parameter of the query to search for and returns in the result the products that match this query.

View File

@@ -161,7 +161,7 @@ Make sure your MeiliSearch instance is running. If youre unsure how to run it
Then, run the Medusa backend:
```bash npm2yarn
npm run start
npx @medusajs/medusa-cli develop
```
The quickest way to test that the integration is working is by sending a `POST` request to `/store/products/search`. This endpoint accepts a `q` body parameter of the query to search for and returns in the result the products that match this query.

View File

@@ -8,7 +8,7 @@ To resolve this issue, make sure you change into the `backend` directory of the
```bash npm2yarn
cd backend
npm run start
npx @medusajs/medusa-cli develop
```
## Other Errors

View File

@@ -5,7 +5,7 @@ If you run into errors after updating Medusa and its dependencies, it's highly r
If there's no upgrade guide for your version, make sure that you ran the `migrations` command in the root directory of your Medusa backend:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
This ensures your backend has the latest database structure required. Then, try running your Medusa backend again and check whether the same error occurs.

View File

@@ -10,7 +10,7 @@ password: supersecret
Alternatively, you can create your own users using the Medusa CLI tool:
```bash
medusa user -e some@email.com -p somepassword
npx @medusajs/medusa-cli user -e some@email.com -p somepassword
```
---

View File

@@ -41,7 +41,7 @@ database_database: "./medusa-db.sql",
Then, migrate the database schema to the new PostgreSQL database:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
:::tip

View File

@@ -33,5 +33,5 @@ To avoid unexpected issues with dependencies, it is also recommended to update a
After updating your Medusa server and before running it, run the following command to run the latest migrations:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```

View File

@@ -4,7 +4,7 @@ description: 'Actions Required for v.1.3.8'
# v1.3.8
Updating your medusa backend to version `1.3.8` may cause issues when using NPM. Please refer to this guide for more details on how to resolve it.
Updating your Medusa backend to version `1.3.8` may cause issues when using NPM. Please refer to this guide for more details on how to resolve it.
## Update Using Yarn

View File

@@ -4,7 +4,7 @@ description: 'Actions Required for v.1.6.1'
# v1.6.1
Updating your medusa backend to version `1.6.1` requires running migrations on your backend.
Updating your Medusa backend to version `1.6.1` requires running migrations on your backend.
## Overview
@@ -19,5 +19,5 @@ Without running the migrations, you might have trouble accessing and using the M
After updating your backend, run migrations with the following command:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```

View File

@@ -21,7 +21,7 @@ In addition, after introducing the Claim Order feature, this version of Medusa i
Run the following command to run migrations:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
### Change Used Methods

View File

@@ -23,7 +23,7 @@ In addition, this version features some fixes to gift cards that requires runnin
In the directory of your Medusa backend, run the following command after updating the backend:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
### Run Migration Script

View File

@@ -33,5 +33,5 @@ It's also recommended to update any other Medusa plugins or packages you have in
After updating your Medusa server and before running it, run the following command to run the latest migrations:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```

View File

@@ -21,7 +21,7 @@ Version 1.7.3 of Medusa keeps the feature flags for these two features, but they
After updating your Medusa backend and before running it, run the following command to run the latest migration:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```
### Run Migration Script for Sales Channels

View File

@@ -35,5 +35,5 @@ It's also recommended to update any other Medusa plugins or packages you have in
After updating your Medusa backend and before running it, run the following command to run the latest migrations:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```

View File

@@ -85,5 +85,5 @@ Make sure to replace `your-redis-url` with the connection URL to your Redis inst
Finally, you should run migrations to ensure your database is up to date with our schema changes:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```

View File

@@ -33,5 +33,5 @@ It's also recommended to update any other Medusa plugins or packages you have in
After updating your Medusa backend and before running it, run the following command to run the latest migrations:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```

View File

@@ -45,5 +45,5 @@ It's also recommended to update any other Medusa plugins or packages you have in
After updating your Medusa backend and before running it, run the following command to run the latest migrations:
```bash
medusa migrations run
npx @medusajs/medusa-cli migrations run
```

View File

@@ -44,7 +44,7 @@ The following data is being collected on your backend:
:::info
💡 Data is only collected when the backend is run with the command `medusa start`.
Data is only collected when the backend is run with the command `medusa start`.
:::
@@ -59,7 +59,7 @@ MEDUSA_DISABLE_TELEMETRY=true
Or, you can run the following command in the root of your Medusa backend project to disable it:
```bash
medusa telemetry --disable
npx @medusajs/medusa-cli telemetry --disable
```
---