This commit is contained in:
parent
09c4f13f2c
commit
2d962d18d2
16 changed files with 520 additions and 89 deletions
76
README.md
76
README.md
|
@ -1,54 +1,8 @@
|
|||
# Plugin Starter Template [](https://circleci.com/gh/mattermost/mattermost-plugin-starter-template)
|
||||
# Plugin Starter Template [](https://circleci.com/gh/mattermost/mattermost-plugin-attachments-remover)
|
||||
|
||||
This plugin serves as a starting point for writing a Mattermost plugin. Feel free to base your own plugin off this repository.
|
||||
## Features
|
||||
|
||||
To learn more about plugins, see [our plugin documentation](https://developers.mattermost.com/extend/plugins/).
|
||||
|
||||
This template requires node v16 and npm v8. You can download and install nvm to manage your node versions by following the instructions [here](https://github.com/nvm-sh/nvm). Once you've setup the project simply run `nvm i` within the root folder to use the suggested version of node.
|
||||
|
||||
## Getting Started
|
||||
Use GitHub's template feature to make a copy of this repository by clicking the "Use this template" button.
|
||||
|
||||
Alternatively shallow clone the repository matching your plugin name:
|
||||
```
|
||||
git clone --depth 1 https://github.com/mattermost/mattermost-plugin-starter-template com.example.my-plugin
|
||||
```
|
||||
|
||||
Note that this project uses [Go modules](https://github.com/golang/go/wiki/Modules). Be sure to locate the project outside of `$GOPATH`.
|
||||
|
||||
Edit the following files:
|
||||
1. `plugin.json` with your `id`, `name`, and `description`:
|
||||
```json
|
||||
{
|
||||
"id": "com.example.my-plugin",
|
||||
"name": "My Plugin",
|
||||
"description": "A plugin to enhance Mattermost."
|
||||
}
|
||||
```
|
||||
|
||||
2. `go.mod` with your Go module path, following the `<hosting-site>/<repository>/<module>` convention:
|
||||
```
|
||||
module github.com/example/my-plugin
|
||||
```
|
||||
|
||||
3. `.golangci.yml` with your Go module path:
|
||||
```yml
|
||||
linters-settings:
|
||||
# [...]
|
||||
goimports:
|
||||
local-prefixes: github.com/example/my-plugin
|
||||
```
|
||||
|
||||
Build your plugin:
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
This will produce a single plugin file (with support for multiple architectures) for upload to your Mattermost server:
|
||||
|
||||
```
|
||||
dist/com.example.my-plugin.tar.gz
|
||||
```
|
||||
- Allows users and sysadmins to delete attachments from posts via a context menu option
|
||||
|
||||
## Development
|
||||
|
||||
|
@ -161,29 +115,5 @@ To trigger a release, follow these steps:
|
|||
|
||||
## Q&A
|
||||
|
||||
### How do I make a server-only or web app-only plugin?
|
||||
|
||||
Simply delete the `server` or `webapp` folders and remove the corresponding sections from `plugin.json`. The build scripts will skip the missing portions automatically.
|
||||
|
||||
### How do I include assets in the plugin bundle?
|
||||
|
||||
Place them into the `assets` directory. To use an asset at runtime, build the path to your asset and open as a regular file:
|
||||
|
||||
```go
|
||||
bundlePath, err := p.API.GetBundlePath()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get bundle path")
|
||||
}
|
||||
|
||||
profileImage, err := ioutil.ReadFile(filepath.Join(bundlePath, "assets", "profile_image.png"))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read profile image")
|
||||
}
|
||||
|
||||
if appErr := p.API.SetProfileImage(userID, profileImage); appErr != nil {
|
||||
return errors.Wrap(err, "failed to set profile image")
|
||||
}
|
||||
```
|
||||
|
||||
### How do I build the plugin with unminified JavaScript?
|
||||
Setting the `MM_DEBUG` environment variable will invoke the debug builds. The simplist way to do this is to simply include this variable in your calls to `make` (e.g. `make dist MM_DEBUG=1`).
|
||||
|
|
Reference in a new issue