The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

gqmt - Graphql Query Mutation Tool

SYNOPSIS

gqmt [-h] <-u USER -R REPO -T TOKEN -P PACKAGE -t query.tt> REST OF OPTIONS

DESCRIPTION

script to clean up old package versions from GitHub repository

OPTIONS

-n | --dry-run

dry run

-a | --age INTEGER

age of version in seconds, to keep. default is 2 weeks

-u | --user STRING

user name of repository owner

-R | --repository STRING

name of the repository to manipulate images of

-t | --query-template STRING

path to query template (see TEMPLATES bellow). Template is injected with these variables:

    repo : repository name

    user : user name

    pkg_num : first num element of packages list

    pkg_name : package name

    vers_num : first num elements from the version files

    cursor : pagination object

-T | --token STRING

personal access token to access the GitHub API

-U | --url STRING

GraphQL API endpoint, default is https://api.github.com/graphql

-P | --package STRING

package name to manage versions of

supported packages are:

--package-regex STRING

regex to exclude package version name from been processed

    api

    app

    scheduler

-N | --rows-number INTEGER

number of rows for reply pagination, max 100 (default 100)

-C | --colored

to use terminal colors in output

-D | --delete

if set, then all versions selected are to be deleted, if option -v is set, then the only one single version is to be deleted (the one, set with -v)

-s | --single-run

process only first page of rows

-v | --package-version

package version to manipulate with

--versions-to-hold

minimum number of versions to hold (default: 2)

-V | --version

version information

-d | --debug

be verbose

-h | --help

help message

EXAMPLE

        gqmt < -u user-name -R repo-name -P pkg-name -T xxxxxxxxxxxxxxxxxx >

    to exclude all versions from been deleted:

        gqmt -u user-name -R repo-name -P pkg-name -T xxxxxxxxxxxxxxxxxx -D --package-regex '.*'

TEMPLATES

Templates are .tt files. Please refer to Template::Toolkit documentation.

See examples in distribution directory etc

Example of query template:

    query { repository(name: "[% repo %]", owner: "[% user %]") {
      packages(first: [% pkg_num %] names: ["[% pkg_name %]"]) {
          nodes {
            id
            name
            versions(last: [% vers_num %][% cursor %]) {
              nodes {
                id
                version
                files(first:1, orderBy: {direction: DESC, field: CREATED_AT}) {
                  totalCount
                  nodes {
                    updatedAt
                  }
                }
              }
              pageInfo {
                endCursor
                hasNextPage
                hasPreviousPage
                startCursor
              }
            }
          }
        }
      }
    }

SEE ALSO

https://docs.github.com/en/graphql/guides/forming-calls-with-graphql

AUTHOR

Zeus Panchenko <zeus@gnu.org.ua>

COPYRIGHT

Copyright 2020 Zeus Panchenko.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.