chore: reorganize docs apps (#7228)
* reorganize docs apps * add README * fix directory * add condition for old docs
This commit is contained in:
1 parent
224ebb2154
commit
4fe28f5a95
6187 files changed
+601447
-598226
No files matched your search
@@ -0,0 +1,184 @@
|
||||
import { Table } from "docs-ui"
|
||||
|
||||
export const metadata = {
|
||||
title: `${pageNumber} Publish a Plugin`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
In this chapter, you’ll learn how to publish a plugin. After you publish your plugin, it will also be available in [Medusa’s Plugins Library](https://medusajs.com/plugins/).
|
||||
|
||||
## package.json Checklist
|
||||
|
||||
Update the following meta information in your plugin’s package.json:
|
||||
|
||||
- `name`: The name of your plugin. By convention, all plugin names start with `medusa` followed by a descriptive name of what the plugin does. For example, `medusa-payment-stripe`.
|
||||
- `description`: A short description of what the plugin does.
|
||||
- `author`: Your name or your company's name.
|
||||
- `repository`: Details about the repository that holds the source code of the plugin. It's an object that holds the following properties:
|
||||
- `type`: Should be `git`.
|
||||
- `url`: The URL to the repository (for example, the GitHub repository holding the code of your plugin).
|
||||
|
||||
### Package Keywords
|
||||
|
||||
It's required for all Medusa plugins to use the keywords `medusa-plugin`.
|
||||
|
||||
The following table mentions other keywords that you can use based on your plugin's functionalities.
|
||||
|
||||
<Table>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell>Keyword</Table.HeaderCell>
|
||||
<Table.HeaderCell>Description</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-analytics`</Table.Cell>
|
||||
<Table.Cell>Analytics functionalities or integrations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-cms`</Table.Cell>
|
||||
<Table.Cell>CMS functionalities or integrations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-notification`</Table.Cell>
|
||||
<Table.Cell>Notification functionalities or integrations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-payment`</Table.Cell>
|
||||
<Table.Cell>Payment functionalities or integrations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-search`</Table.Cell>
|
||||
<Table.Cell>Search functionalities or integrations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-shipping`</Table.Cell>
|
||||
<Table.Cell>Shipping functionalities or integrations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-storage`</Table.Cell>
|
||||
<Table.Cell>File service or storage integrations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-source`</Table.Cell>
|
||||
<Table.Cell>Migrate or import data into Medusa from another platform.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-admin`</Table.Cell>
|
||||
<Table.Cell>Plugins that include only admin customizations.</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>`medusa-plugin-other`</Table.Cell>
|
||||
<Table.Cell>Any other type of plugin.</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table.Body>
|
||||
</Table>
|
||||
|
||||
---
|
||||
|
||||
## Add NPMIgnore File
|
||||
|
||||
Not all files in your Medusa application are relevant to the published plugin.
|
||||
|
||||
Add the following `.npmignore` file in the root of the plugin's directory to ignore unnecessary files from the published plugin:
|
||||
|
||||
```bash title=".npmignore"
|
||||
# directories
|
||||
.cache
|
||||
.DS_store
|
||||
.github
|
||||
.vscode
|
||||
.yarn
|
||||
build
|
||||
data
|
||||
node_modules
|
||||
src
|
||||
uploads
|
||||
|
||||
# files
|
||||
.babelrc
|
||||
.env*
|
||||
.gitignore
|
||||
.eslintrc
|
||||
.prettierrc
|
||||
.yarnrc.yml
|
||||
index.js
|
||||
medusa-config.js
|
||||
yarn.lock
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Publish Plugin
|
||||
|
||||
<Note type="check">
|
||||
|
||||
To publish a plugin, you need an [NPM account](https://www.npmjs.com/signup).
|
||||
|
||||
</Note>
|
||||
|
||||
To publish the plugin:
|
||||
|
||||
1. Run the `prepare` command:
|
||||
|
||||
```bash npm2yarn
|
||||
npm run prepare
|
||||
```
|
||||
|
||||
2. Publish the NPM package:
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
If you haven’t logged in before with NPM, you’ll be asked to log in first.
|
||||
|
||||
Your package is then published to NPM.
|
||||
|
||||
---
|
||||
|
||||
## Install Plugin in Medusa Applications
|
||||
|
||||
To install your published plugin in a Medusa application, run the following command:
|
||||
|
||||
```bash npm2yarn
|
||||
npm install medusa-plugin-custom
|
||||
```
|
||||
|
||||
Where `medusa-plugin-custom` is your plugin’s name.
|
||||
|
||||
Then, add the plugin to `medusa-config.js`:
|
||||
|
||||
```js title="medusa-config.js"
|
||||
const plugins = [
|
||||
// ...
|
||||
{
|
||||
resolve: `medusa-plugin-custom`,
|
||||
options: {
|
||||
// plugin options...
|
||||
},
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Update Plugin
|
||||
|
||||
To publish plugin changes, first, run the following command in the plugin’s directory to change the NPM version:
|
||||
|
||||
```bash
|
||||
npm version <type>
|
||||
```
|
||||
|
||||
Where `<type>` indicates the type of version update you’re publishing. For example, `major`. You can see the [full list of types in NPM’s documentation](https://docs.npmjs.com/cli/v8/commands/npm-version).
|
||||
|
||||
Then, publish the new update:
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
You can then update the plugin in the Medusa applications that use it.
|
||||
Reference in new issue
Block a user