Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-23044: Bootstrap channel export plugin and add a dummy exporter #1

Merged
merged 8 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,37 +1,25 @@
# 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.

## 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 @@ -52,32 +40,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