diff --git a/docs/content/development/entities/create.md b/docs/content/development/entities/create.md index fc5d084cfe..502214873a 100644 --- a/docs/content/development/entities/create.md +++ b/docs/content/development/entities/create.md @@ -186,4 +186,4 @@ With entities, you can create relationships, index keys, and more. As Medusa use ## See Also - [Extend Entity](./extend-entity.md) -- [Create a Plugin](../plugins/create.md) +- [Create a Plugin](../plugins/create.mdx) diff --git a/docs/content/development/entities/migrations/create.md b/docs/content/development/entities/migrations/create.md index 992f957cbd..e01c94532f 100644 --- a/docs/content/development/entities/migrations/create.md +++ b/docs/content/development/entities/migrations/create.md @@ -17,7 +17,7 @@ npx typeorm migration:create src/migrations/UserChanged This will create the migration file in the path you specify. You can use this without the need to install Typeorm's CLI tool. You can then go ahead and make changes to it as necessary. -The migration file must be inside the `src/migrations` directory. When you run the build command, it will be transpiled into the directory `dist/migrations`. The `migrations run` command can only pick up migrations under the `dist/migrations` directory on a Medusa backend. This applies to migrations created in a Medusa backend, and not in a Medusa plugin. For plugins, check out the [Plugin's Structure section](../../plugins/create.md). +The migration file must be inside the `src/migrations` directory. When you run the build command, it will be transpiled into the directory `dist/migrations`. The `migrations run` command can only pick up migrations under the `dist/migrations` directory on a Medusa backend. This applies to migrations created in a Medusa backend, and not in a Medusa plugin. For plugins, check out the [Plugin's Structure section](../../plugins/create.mdx).
Generating Migrations for Entities @@ -99,4 +99,4 @@ If you check your database now you should see that the change defined by the mig ## See Also -- [Create a Plugin](../../plugins/create.md) +- [Create a Plugin](../../plugins/create.mdx) diff --git a/docs/content/development/events/create-subscriber.md b/docs/content/development/events/create-subscriber.md index a28913ddbd..9ae74456b9 100644 --- a/docs/content/development/events/create-subscriber.md +++ b/docs/content/development/events/create-subscriber.md @@ -96,4 +96,4 @@ When using attributes defined in the subscriber, such as the `productService` in ## See Also -- [Create a Plugin](../plugins/create.md) \ No newline at end of file +- [Create a Plugin](../plugins/create.mdx) \ No newline at end of file diff --git a/docs/content/development/file-service/create-file-service.md b/docs/content/development/file-service/create-file-service.md index 44e8f71fa7..a2175cdceb 100644 --- a/docs/content/development/file-service/create-file-service.md +++ b/docs/content/development/file-service/create-file-service.md @@ -390,7 +390,7 @@ npm run build :::note -This section explains how to test out your implementation if the file service was created in the Medusa backend codebase. You can refer to the [plugin documentation](../plugins/create.md#test-your-plugin) on how to test a plugin. +This section explains how to test out your implementation if the file service was created in the Medusa backend codebase. You can refer to the [plugin documentation](../plugins/create.mdx#test-your-plugin) on how to test a plugin. ::: @@ -430,5 +430,5 @@ export default () => { ## See Also -- [How to create a plugin](../plugins/create.md) +- [How to create a plugin](../plugins/create.mdx) - [How to publish a plugin](../plugins/publish.md) diff --git a/docs/content/development/fundamentals/local-development.md b/docs/content/development/fundamentals/local-development.md index beb6b0aeea..b85bb639c3 100644 --- a/docs/content/development/fundamentals/local-development.md +++ b/docs/content/development/fundamentals/local-development.md @@ -190,5 +190,5 @@ medusa-dev --packages @medusajs/medusa-cli medusa-file-minio ## See Also -- [Create a Plugin](../plugins/create.md) +- [Create a Plugin](../plugins/create.mdx) - [Contribution Guidelines](https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md) diff --git a/docs/content/development/loaders/create.md b/docs/content/development/loaders/create.md index 3e0f2279a8..0153f19766 100644 --- a/docs/content/development/loaders/create.md +++ b/docs/content/development/loaders/create.md @@ -73,7 +73,7 @@ npm run build :::note -This section explains how to test out the loader if it’s created in the Medusa backend codebase. If you’re creating your loader in a plugin, you can learn how to test it in the [plugins documentation](../plugins/create.md#test-your-plugin). Alternatively, if you’re creating your loader in a module, you can learn how to test it in the [modules documentation](../modules/create.mdx#step-4-test-your-module). +This section explains how to test out the loader if it’s created in the Medusa backend codebase. If you’re creating your loader in a plugin, you can learn how to test it in the [plugins documentation](../plugins/create.mdx#test-your-plugin). Alternatively, if you’re creating your loader in a module, you can learn how to test it in the [modules documentation](../modules/create.mdx#step-4-test-your-module). ::: diff --git a/docs/content/development/notification/create-notification-provider.md b/docs/content/development/notification/create-notification-provider.md index 89071d74a5..de5e4fd0d4 100644 --- a/docs/content/development/notification/create-notification-provider.md +++ b/docs/content/development/notification/create-notification-provider.md @@ -343,4 +343,4 @@ This request returns the same notification object as the List Notifications endp ## See Also -- [Create a Plugin](../plugins/create.md) +- [Create a Plugin](../plugins/create.mdx) diff --git a/docs/content/development/plugins/create.md b/docs/content/development/plugins/create.mdx similarity index 77% rename from docs/content/development/plugins/create.md rename to docs/content/development/plugins/create.mdx index 1174b70277..8607a5530c 100644 --- a/docs/content/development/plugins/create.md +++ b/docs/content/development/plugins/create.mdx @@ -3,6 +3,9 @@ description: 'Learn how to create a plugin in Medusa. This guide explains how to addHowToData: true --- +import DocCardList from '@theme/DocCardList'; +import Icons from '@theme/Icon'; + # How to Create a Plugin In this document, you’ll learn how to create a plugin and some tips for develoment. If you’re interested to learn more about what plugins are and where to find available official and community plugins, check out the [overview document](./overview.mdx). @@ -90,6 +93,16 @@ Once you’re done making these changes, re-run the install command to update yo npm install ``` +Then, make sure to remove the plugins and modules you removed from `medusa-config.js`: + +```js title=medusa-config.js +// previously had plugins +const plugins = [] + +// previously had modules +const modules = {} +``` + ### Recommended: Change Scripts It's recommended to remove the `seed` and `start` scripts from your `package.json` as they aren't necessary for plugin development. @@ -135,11 +148,97 @@ It was previously required to output your files into the root of the plugin's di This guide doesn't cover how to create different files and components. If you’re interested in learning how to do that, you can check out these guides: -- How to [create endpoints](../endpoints/create.md) -- How to [create a service](../services/create-service.mdx) -- How to [create a subscriber](../events/create-subscriber.md) -- How to [create an entity](../entities/create.md) -- How to [create a migration](../entities/migrations/create.md) + + +If you're developing something specific, such as a payment processor plugin, you can follow one of the following guides to learn how to create different services within your plugin. + + + + --- @@ -149,7 +248,7 @@ Plugins often allow developers that will later use them to enter their own confi To pass a plugin its configurations on a Medusa backend, you have to add it to the `plugins` array in `medusa-config.js`: -```jsx title=medusa-config.js +```js title=medusa-config.js const plugins = [ // ... { @@ -163,7 +262,7 @@ const plugins = [ Then, you can have access to your plugin configuration in the constructor of services in your plugin: -```jsx title=src/service/test.ts +```js title=src/service/test.ts // In a service in your plugin class MyService extends TransactionBaseService { constructor(container, options) { @@ -177,7 +276,7 @@ class MyService extends TransactionBaseService { You can also have access to the configurations in endpoints in your plugin: -```jsx title=src/api/index.ts +```js title=src/api/index.ts // in an endpoint in your plugin export default (rootDirectory, options) => { // options contain the plugin configurations diff --git a/docs/content/development/plugins/overview.mdx b/docs/content/development/plugins/overview.mdx index 126596a6df..5c31d28114 100644 --- a/docs/content/development/plugins/overview.mdx +++ b/docs/content/development/plugins/overview.mdx @@ -7,7 +7,7 @@ import Icons from '@theme/Icon'; # Plugins -In this document, you’ll get an overview of plugins in Medusa, where to find them, and how to install them. If you want to learn how to create a plugin, check out [this guide](create.md) instead. +In this document, you’ll get an overview of plugins in Medusa, where to find them, and how to install them. If you want to learn how to create a plugin, check out [this guide](create.mdx) instead. ## Overview diff --git a/docs/content/development/plugins/publish.md b/docs/content/development/plugins/publish.md index e084d0235d..cc294a159a 100644 --- a/docs/content/development/plugins/publish.md +++ b/docs/content/development/plugins/publish.md @@ -9,7 +9,7 @@ In this document, you'll learn how to publish a Medusa plugin to NPM and what ar ## Prerequisites -If you haven't created a plugin yet, please check [this guide to learn how to create a plugin](./create.md). +If you haven't created a plugin yet, please check [this guide to learn how to create a plugin](./create.mdx). --- @@ -46,7 +46,7 @@ Make sure you add the `publish` command to your `scripts` field and make the fol "prepare": "cross-env NODE_ENV=production npm run build" ``` -The `build` command ensures that the plugin's built files are placed as explained in the [plugin structure](./create.md#plugin-structure) section of the Create Plugin documentation. +The `build` command ensures that the plugin's built files are placed as explained in the [plugin structure](./create.mdx#plugin-structure) section of the Create Plugin documentation. The `prepare` command facilitates your publishing process. You would typically run this script before publishing your plugin. @@ -58,7 +58,7 @@ npm install --save-dev cross-env ### Plugin Structure -Make sure your plugin's structure is as described in the [Create Plugin](./create.md#plugin-structure) documentation. If you've made the changes mentioned in [the above section to the scripts](#scripts-in-packagejson) in `package.json`, you should have the correct structure when you run the `prepare` command. +Make sure your plugin's structure is as described in the [Create Plugin](./create.mdx#plugin-structure) documentation. If you've made the changes mentioned in [the above section to the scripts](#scripts-in-packagejson) in `package.json`, you should have the correct structure when you run the `prepare` command. ### NPM Ignore File diff --git a/docs/content/development/scheduled-jobs/create.md b/docs/content/development/scheduled-jobs/create.md index 6a86114944..2725acdb5e 100644 --- a/docs/content/development/scheduled-jobs/create.md +++ b/docs/content/development/scheduled-jobs/create.md @@ -177,4 +177,4 @@ To test the previous example out instantly, you can change the scheduled job exp ## See Also -- [Create a Plugin](../plugins/create.md) \ No newline at end of file +- [Create a Plugin](../plugins/create.mdx) \ No newline at end of file diff --git a/docs/content/development/search/create.md b/docs/content/development/search/create.md index 3e8e795319..cf7913e855 100644 --- a/docs/content/development/search/create.md +++ b/docs/content/development/search/create.md @@ -396,7 +396,7 @@ npm run build :::note -This section explains how to test out your implementation if the search service was created in the Medusa backend codebase. You can refer to [the plugin documentation](../plugins/create.md#test-your-plugin) on how to test a plugin. +This section explains how to test out your implementation if the search service was created in the Medusa backend codebase. You can refer to [the plugin documentation](../plugins/create.mdx#test-your-plugin) on how to test a plugin. ::: @@ -412,5 +412,5 @@ You can then send a request to the [Search Products endpoint](/api/store#tag/Pro ## See Also -- [How to create a plugin](../plugins/create.md) +- [How to create a plugin](../plugins/create.mdx) - [How to publish a plugin](../plugins/publish.md) diff --git a/docs/content/development/services/create-service.mdx b/docs/content/development/services/create-service.mdx index f85b9871b4..ec873886b7 100644 --- a/docs/content/development/services/create-service.mdx +++ b/docs/content/development/services/create-service.mdx @@ -161,4 +161,4 @@ class MySubscriber { ## See Also -- [Create a Plugin](../plugins/create.md) +- [Create a Plugin](../plugins/create.mdx) diff --git a/docs/content/development/services/overview.mdx b/docs/content/development/services/overview.mdx index 7ddf817865..fec7b3d7f2 100644 --- a/docs/content/development/services/overview.mdx +++ b/docs/content/development/services/overview.mdx @@ -31,7 +31,7 @@ The service must then be transpiled using the `build` command, which moves them :::tip -If you're creating a service in a plugin, learn more about the required structure [here](../plugins/create.md#plugin-structure). +If you're creating a service in a plugin, learn more about the required structure [here](../plugins/create.mdx#plugin-structure). ::: diff --git a/docs/content/plugins/cms/strapi.md b/docs/content/plugins/cms/strapi.md index e7e929e627..ae40863660 100644 --- a/docs/content/plugins/cms/strapi.md +++ b/docs/content/plugins/cms/strapi.md @@ -199,4 +199,4 @@ If you try to update products on Medusa either using the [REST APIs](/api/admin/ ## See Also - [Deploy the Medusa backend](../../deployments/server/index.mdx) -- [Create your own plugin](../../development/plugins/create.md) +- [Create your own plugin](../../development/plugins/create.mdx)