Skip to content

Commit

Permalink
MM-23044: Bootstrap channel export plugin and add a dummy exporter (#1)
Browse files Browse the repository at this point in the history
* Bootstrap channel export plugin

- Delete the webapp directory, as for now, we only need the server part
- Adapt plugin.json and regenerates server/manifest.go
- Add mattermost-plugin-api dependency
- Adapt README from the starter template

* Set up the plugin structure and a dummy exporter

- Ensure a bot when activating the plugin.
- Add a command, /export, to export a channel. For the moment, it just
 outputs an empty JSON.

* Use plugin-ci orb

* Fix bot description

Co-Authored-By: Jesse Hallam <[email protected]>

* Reword autocomplete description

Co-Authored-By: Jesse Hallam <[email protected]>

* Remove unused code

* Address PR minor comments

- Make err handling more idiomatic
- Rename exportCommandTrigger variable

* Decouple communication to user and export process

Co-authored-by: Jesse Hallam <[email protected]>
  • Loading branch information
agarciamontoro and lieut-data committed Aug 5, 2020
1 parent 8ff070d commit e09ae7c
Show file tree
Hide file tree
Showing 23 changed files with 394 additions and 16,654 deletions.
68 changes: 47 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
version: 2.1
executors:
default:
docker:
- image: circleci/golang:1.14-node

jobs:
lint:
executor:
name: default
steps:
- checkout
- run: make check-style

test:
executor:
name: default
steps:
- checkout
- run: make test
orbs:
plugin-ci: mattermost/plugin-ci@volatile

workflows:
version: 2
untagged-build:
ci:
jobs:
- lint
- test
- plugin-ci/lint:
filters:
tags:
only: /^v.*/
- plugin-ci/coverage:
filters:
tags:
only: /^v.*/
- plugin-ci/build:
filters:
tags:
only: /^v.*/
- plugin-ci/deploy-ci:
filters:
branches:
only: master
context: plugin-ci
requires:
- plugin-ci/lint
- plugin-ci/coverage
- plugin-ci/build
- plugin-ci/deploy-release:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
context: plugin-ci
requires:
- plugin-ci/lint
- plugin-ci/coverage
- plugin-ci/build
- plugin-ci/deploy-release-github:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
context: matterbuild-github-token
requires:
- plugin-ci/lint
- plugin-ci/coverage
- plugin-ci/build

53 changes: 6 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
# Plugin Starter Template [![CircleCI branch](https://img.shields.io/circleci/project/github/mattermost/mattermost-plugin-starter-template/master.svg)](https://circleci.com/gh/mattermost/mattermost-plugin-starter-template)
# Mattermost Channel Export Plugin

This plugin serves as a starting point for writing a Mattermost plugin. Feel free to base your own plugin off this repository.

To learn more about plugins, see [our plugin documentation](https://developers.mattermost.com/extend/plugins/).
This plugin allows channel export into a human readable format.

## License

This repository is licensed under the [Mattermost Source Available License](LICENSE) and requires a valid Enterprise E20 license. See [Mattermost Source Available License](https://docs.mattermost.com/overview/faq.html#mattermost-source-available-license) to learn more.

## Getting Started
Use GitHub's template feature to make a copy of this repository by clicking the "Use this template" button then clone outside of `$GOPATH`.

Alternatively shallow clone the repository to a directory outside of `$GOPATH` matching your plugin name:
Clone the repository to a directory outside of `$GOPATH`
```
git clone --depth 1 https://github.com/mattermost/mattermost-plugin-starter-template com.example.my-plugin
git clone https://github.com/mattermost/mattermost-plugin-channel-export.git
```

Note that this project uses [Go modules](https://github.com/golang/go/wiki/Modules). Be sure to locate the project outside of `$GOPATH`, or allow the use of Go modules within your `$GOPATH` with an `export GO111MODULE=on`.

Edit `plugin.json` with your `id`, `name`, and `description`:
```
{
"id": "com.example.my-plugin",
"name": "My Plugin",
"description": "A plugin to enhance Mattermost."
}
```

Build your plugin:
Build the 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
dist/com.mattermost.plugin-channel-export.tar.gz
```

There is a build target to automate deploying and enabling the plugin to your server, but it requires login credentials:
Expand All @@ -56,32 +44,3 @@ make deploy
Alternatively, if you are running your `mattermost-server` out of a sibling directory by the same name, use the `deploy` target alone to unpack the files into the right directory. You will need to restart your server and manually enable your plugin.

In production, deploy and upload your plugin via the [System Console](https://about.mattermost.com/default-plugin-uploads).

## 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?
Use `make debug-dist` and `make debug-deploy` in place of `make dist` and `make deploy` to configure webpack to generate unminified Javascript.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/mattermost/mattermost-plugin-starter-template
go 1.12

require (
github.com/mattermost/mattermost-server/v5 v5.20.0
github.com/mattermost/mattermost-plugin-api v0.0.9
github.com/mattermost/mattermost-server/v5 v5.3.2-0.20200313113657-e2883bfe5f37
github.com/mholt/archiver/v3 v3.3.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.5.1
Expand Down
Loading

0 comments on commit e09ae7c

Please sign in to comment.