gameStatusUpdate/README.md

221 lines
6.6 KiB
Markdown
Raw Normal View History

2024-09-18 07:59:20 -07:00
# 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)
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 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
```
## Development
To avoid having to manually install your plugin, build and deploy your plugin using one of the following options. In order for the below options to work, you must first enable plugin uploads via your config.json or API and restart Mattermost.
```json
"PluginSettings" : {
...
"EnableUploads" : true
}
```
### Deploying with Local Mode
If your Mattermost server is running locally, you can enable [local mode](https://docs.mattermost.com/administration/mmctl-cli-tool.html#local-mode) to streamline deploying your plugin. Edit your server configuration as follows:
```json
{
"ServiceSettings": {
...
"EnableLocalMode": true,
"LocalModeSocketLocation": "/var/tmp/mattermost_local.socket"
},
}
```
and then deploy your plugin:
```
make deploy
```
You may also customize the Unix socket path:
```bash
export MM_LOCALSOCKETPATH=/var/tmp/alternate_local.socket
make deploy
```
If developing a plugin with a webapp, watch for changes and deploy those automatically:
```bash
export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_TOKEN=j44acwd8obn78cdcx7koid4jkr
make watch
```
### Deploying with credentials
Alternatively, you can authenticate with the server's API with credentials:
```bash
export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_USERNAME=admin
export MM_ADMIN_PASSWORD=password
make deploy
```
or with a [personal access token](https://docs.mattermost.com/developer/personal-access-tokens.html):
```bash
export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_TOKEN=j44acwd8obn78cdcx7koid4jkr
make deploy
```
### Releasing new versions
The version of a plugin is determined at compile time, automatically populating a `version` field in the [plugin manifest](plugin.json):
* If the current commit matches a tag, the version will match after stripping any leading `v`, e.g. `1.3.1`.
* Otherwise, the version will combine the nearest tag with `git rev-parse --short HEAD`, e.g. `1.3.1+d06e53e1`.
* If there is no version tag, an empty version will be combined with the short hash, e.g. `0.0.0+76081421`.
To disable this behaviour, manually populate and maintain the `version` field.
## How to Release
To trigger a release, follow these steps:
1. **For Patch Release:** Run the following command:
```
make patch
```
This will release a patch change.
2. **For Minor Release:** Run the following command:
```
make minor
```
This will release a minor change.
3. **For Major Release:** Run the following command:
```
make major
```
This will release a major change.
4. **For Patch Release Candidate (RC):** Run the following command:
```
make patch-rc
```
This will release a patch release candidate.
5. **For Minor Release Candidate (RC):** Run the following command:
```
make minor-rc
```
This will release a minor release candidate.
6. **For Major Release Candidate (RC):** Run the following command:
```
make major-rc
```
This will release a major release candidate.
## 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`).
###
###
###
### Creating a new repository on the command line
2024-09-18 08:53:20 -07:00
* touch README.md
* git init
* git checkout -b main
* git add README.md
* git commit -m "first commit"
* git remote add origin https://gitlab.peanutsmediaserver.com/aaron/gameStatusUpdate.git
* git push -u origin main
###
###
###
###
2024-09-18 08:53:20 -07:00
## DONT FORGET TO DO THIS BEFORE COMMITING CHANGES
* make clean
* make
2024-09-18 07:59:20 -07:00
2024-09-18 08:27:46 -07:00
### Pushing an existing repository from the command line with version tag
2024-09-18 08:53:20 -07:00
* git add .
* git commit -m "comment for the commit"
* git tag -a vX.X.X -m "version X.X.X"
* git push origin vX.X.X
* git push origin main
* git push --tags
### last version commited v0.1.0