diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-lint.yml similarity index 68% rename from .github/workflows/python-package.yml rename to .github/workflows/python-lint.yml index 668a43f..dd4929e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-lint.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python package +name: Python Lints and Tests on: [push, pull_request] @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 @@ -24,12 +24,13 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --statistics + - name: Lint Code Base + uses: github/super-linter@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_PYTHON_PYLINT: false + LINTER_RULES_PATH: . + PYTHON_BLACK_CONFIG_FILE: pyproject.toml - name: Run pluploader --version run: | pip install . diff --git a/Dockerfile b/Dockerfile index c6ccd0a..7c233ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ FROM python:3.8 -ARG PL_VERSION +ARG PL_VERSION=">=0.3" RUN mkdir /workdir -RUN pip3 install pluploader==$PL_VERSION +RUN pip3 install "pluploader==$PL_VERSION" WORKDIR /workdir -ENTRYPOINT [ "pluploader" ]% +ENTRYPOINT [ "pluploader" ] diff --git a/README.md b/README.md index aab7c02..5fbbeed 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ -## pluploader + + +# pluploader ![PyPI version](https://img.shields.io/pypi/v/pluploader?style=flat-square) ![Upload Python Package](https://img.shields.io/github/workflow/status/livelyapps/pluploader/Python%20package/master?style=flat-square) -A simple command line plugin uploader/installer/manager for atlassian product +A simple command line plugin uploader/installer/manager for atlassian product server instances (Confluence/Jira) written in python(3). ## Installation @@ -11,7 +19,7 @@ Regulary tested on Linux (Arch Linux), MacOS and Windows 10. ### pip (recommended) -``` +```bash pip3 install pluploader ``` @@ -28,11 +36,12 @@ docker pull docker.pkg.github.com/livelyapps/pluploader/pluploader:latest pluploader can then be run by executing -``` +```bash docker run -v "$(pwd)":/workdir -it craftamap/pluploader:v0.4.1 ``` ## Usage + For a in-depth explanation, see `pluploader --help` > ℹ This documentation describes the master branch, and not (necessarily) the latest release. @@ -40,6 +49,7 @@ For a in-depth explanation, see `pluploader --help` ### Global Options You can specify various global options: + - `--base-url `, default: `http://localhost:8090` - `--user `, default: `admin` - `--password `, default: `admin` @@ -54,40 +64,40 @@ All Global Options can be overwritten by using a configuration file. See more in If you are in a maven project, the basic usage is fairly simple. Just type: -``` +```bash pluploader --user admin --password admin ``` -The pluploader then uploads and enables the current artifact specified in the +The pluploader then uploads and enables the current artifact specified in the pom.xml If you are not in a maven directory currently, but you want to upload a specific file, you can also use the `-f plugin.jar` flag. -If you want to confirm your upload, you can also use the `-i` / +If you want to confirm your upload, you can also use the `-i` / `--interactive` flag. It is recommended to use the pluploader with maven. The usage looks like: -``` +```bash atlas-mvn clean package && pluploader ``` #### Installing apps from the marketplace -pluploader supports downloading apps from the atlassian marketplace to your local +pluploader supports downloading apps from the atlassian marketplace to your local machine and installing them afterwards. You need to supply either `--mpac-key`, -which is the normal addon-key, or `--mpac-id` (experimental), which is the +which is the normal addon-key, or `--mpac-id` (experimental), which is the numeric id of an marketplace id (72307 https://marketplace.atlassian.com/apps/72307) -``` +```bash pluploader --mpac-key com.atlassian.confluence.extra.team-calendars ``` -**NOTE**: +**NOTE**: If you specify one of the global options, you need to add the `install`-command: -``` +```bash pluploader --base-url https://your-confluence.com:8090 install ``` @@ -110,7 +120,7 @@ indicates that the plugin is disabled. In order to retrieve more information about a specific plugin, you can use the command `info`. -``` +```bash pluploader info com.example.plugin.key ``` @@ -124,19 +134,20 @@ The commands `enable`, `disable` or `uninstall` follow the same syntax. pluploader also supports disabling or enabling all apps using Safe Mode. To retrieve the status if safe-mode is enabled at the moment, use -``` + +```bash pluploader safe-mode status ``` -You can enable and disable safe mode by using +You can enable and disable safe mode by using -``` +```bash pluploader safe-mode enable ``` And -``` +```bash pluploader safe-mode disable # OR pluploader safe-mode disable --keep-state @@ -148,7 +159,7 @@ You can also use the pluploader to get and set licenses for your plugins. To get the current license information: -``` +```bash pluploader license info com.example.plugin.key ``` @@ -159,9 +170,9 @@ pluploader license update com.example.plugin.key --license "AAA..." ``` > ℹ Pro tip: Use `xargs` to read a license from a file by using -> +> > ```bash -> cat license.txt | xargs pluploader license update --license +> cat license.txt | xargs pluploader license update --license > ``` You can also apply [timebomb licenses](https://developer.atlassian.com/platform/marketplace/timebomb-licenses-for-testing-server-apps/) @@ -169,7 +180,7 @@ You can also apply [timebomb licenses](https://developer.atlassian.com/platform/ by using ```bash -pluploader license timebomb com.example.plugin.key --timebomb threehours +pluploader license timebomb com.example.plugin.key --timebomb threehours ``` You can choose between 3 hours (threehours), 60 seconds (sixtyseconds) and @@ -178,12 +189,12 @@ You can choose between 3 hours (threehours), 60 seconds (sixtyseconds) and To remove an applied license, you can use: ```bash -pluploader license delete com.example.plugin.key +pluploader license delete com.example.plugin.key ``` ### Scheduled Jobs (Confluence - Experimental) -> ℹ This feature is currently experimental and only works in specific version of +> ℹ This feature is currently experimental and only works in specific version of > Confluence (tested on Confluence 7.5). Pluploader can also be used to retrieve information about confluence jobs and @@ -191,45 +202,47 @@ execute them. You can grab a list of all jobs by running -``` +```bash pluploader job list ``` -Available options are: - - `--hide-default` - Hides confluence internal jobs - - `--print-all-infos` - print more informations +Available options are: + +- `--hide-default` - Hides confluence internal jobs +- `--print-all-infos` - print more informations You can also run jobs by running -``` +```bash pluploader job run ``` Get more information about a job by running -``` +```bash pluploader job info ``` And disable or enable jobs by running -``` -pluploader job enable + +```bash +pluploader job enable # AND pluploader job disable ``` -A job can be specified by either using `--id ` or by using -`--idx `. If no job is specified, you will be asked +A job can be specified by either using `--id ` or by using +`--idx `. If no job is specified, you will be asked interactively. ### Configuration -If you don't want to write the username or password (or any other global -parameter) each time, you can use a filed called `.pluprc`, either placed in -your current maven project or/and in your home directory. A example looks like +If you don't want to write the username or password (or any other global +parameter) each time, you can use a filed called `.pluprc`, either placed in +your current maven project or/and in your home directory. A example looks like this: -``` +```bash base_url: https://example.com:8090 user: admin password: admin @@ -237,7 +250,7 @@ password: admin ### Environment variables -You can also specify username, password and base url by using `PLUP_USER`, +You can also specify username, password and base url by using `PLUP_USER`, `PLUP_PASSWORD` and `PLUP_BASEURL`. ## Development @@ -248,7 +261,7 @@ pluploader uses [poetry](https://python-poetry.org/) as it's package manager. As ### Why would I use the pluploader over X? -Of course, you can use whatever tool you want to. +Of course, you can use whatever tool you want to. ### Why would I use the pluploader over the UPM? diff --git a/pluploader/confluence/jobs/jobs.py b/pluploader/confluence/jobs/jobs.py index 9689b60..2f2f0a9 100644 --- a/pluploader/confluence/jobs/jobs.py +++ b/pluploader/confluence/jobs/jobs.py @@ -125,11 +125,7 @@ def disable_job(self, job: Job, token: typing.Optional[str] = None,) -> bool: response = self.session.get(request_url) return response.status_code == 200 - def enable_job( - self, - job: Job, - token: typing.Optional[str] = None, - ) -> bool: + def enable_job(self, job: Job, token: typing.Optional[str] = None,) -> bool: if token is None: token = self.get_token() request_url = self.base_url.copy() diff --git a/pluploader/job.py b/pluploader/job.py index bf1b9dc..8279bee 100644 --- a/pluploader/job.py +++ b/pluploader/job.py @@ -1,13 +1,14 @@ import logging import shutil import sys +import typing import requests import typer -import typing +from colorama import Fore + from .confluence.jobs import jobs from .confluence.jobs.jobs import JobsScraper -from colorama import Fore app_job = typer.Typer() diff --git a/pluploader/main.py b/pluploader/main.py index 699f0bc..7d62ff3 100755 --- a/pluploader/main.py +++ b/pluploader/main.py @@ -22,8 +22,8 @@ from .mpac import download from .mpac.exceptions import MpacAppNotFoundError, MpacAppVersionNotFoundError from .safemode import app_safemode -from .upm.upmcloudapi import UpmCloudApi from .upm.upmapi import UpmApi +from .upm.upmcloudapi import UpmCloudApi from .util import atlassian_jar as jar from .util import pathutil diff --git a/pluploader/mpac/download.py b/pluploader/mpac/download.py index 524ed30..73d05bb 100644 --- a/pluploader/mpac/download.py +++ b/pluploader/mpac/download.py @@ -6,8 +6,7 @@ import requests from furl import furl -from . import scraper -from . import rest +from . import rest, scraper def _download_file_to_tmp_dir(url: furl) -> os.PathLike: diff --git a/pluploader/mpac/rest.py b/pluploader/mpac/rest.py index 63514d0..7fc2c00 100644 --- a/pluploader/mpac/rest.py +++ b/pluploader/mpac/rest.py @@ -3,10 +3,11 @@ """ import dataclasses +import typing import requests -import typing from furl import furl + from .exceptions import MpacAppVersionNotFoundError BASE_URL = furl("https://marketplace.atlassian.com/rest/2") diff --git a/pluploader/mpac/scraper.py b/pluploader/mpac/scraper.py index 33794e9..036e5b5 100644 --- a/pluploader/mpac/scraper.py +++ b/pluploader/mpac/scraper.py @@ -4,7 +4,8 @@ import requests from bs4 import BeautifulSoup from furl import furl -from .exceptions import (MpacAppNotFoundError, MpacAppVersionNotFoundError) + +from .exceptions import MpacAppNotFoundError, MpacAppVersionNotFoundError VERSION_HISTORY_URL = "https://marketplace.atlassian.com/apps/{}/WILDCARD/version-history" diff --git a/pluploader/safemode.py b/pluploader/safemode.py index 758014b..d1f9892 100644 --- a/pluploader/safemode.py +++ b/pluploader/safemode.py @@ -1,9 +1,10 @@ -import typer -from colorama import Fore import logging -import requests import sys +import requests +import typer +from colorama import Fore + from .upm.upmapi import UpmApi app_safemode = typer.Typer() diff --git a/pluploader/upm/upmcloudapi.py b/pluploader/upm/upmcloudapi.py index 2b5c3e4..50e9c42 100644 --- a/pluploader/upm/upmcloudapi.py +++ b/pluploader/upm/upmcloudapi.py @@ -3,8 +3,8 @@ import requests from furl import furl -from .upmapi import PluginDto, UpmApi from .exceptions import UploadFailedException +from .upmapi import PluginDto, UpmApi class UpmCloudApi(UpmApi): diff --git a/pluploader/util/atlassian_jar.py b/pluploader/util/atlassian_jar.py index f713a5e..c28902d 100644 --- a/pluploader/util/atlassian_jar.py +++ b/pluploader/util/atlassian_jar.py @@ -4,7 +4,9 @@ import pathlib from zipfile import ZipFile + from bs4 import BeautifulSoup + from .pathutil import PluginKeyNotFoundError