#!/bin/sh #! -*-perl-*- eval 'exec perl -x -wS $0 ${1+"$@"}' if 0; # # -*- mode: cperl; eval: (follow-mode) -*- # use strict; use warnings; use App::gqmt; App::gqmt->new->run; __END__ =head1 NAME gqmt - Graphql Query Mutation Tool =head1 SYNOPSIS gqmt [-h] <-u USER -R REPO -T TOKEN -P PACKAGE -t query.tt> REST OF OPTIONS =head1 DESCRIPTION script to clean up old package versions from GitHub repository =head1 OPTIONS =over 4 =item B<-n | --dry-run> dry run =item B<-a | --age> I age of version in seconds, to keep. default is 2 weeks =item B<-u | --user> I user name of repository owner =item B<-R | --repository> I name of the repository to manipulate images of =item B<-t | --query-template> I path to query template (see B bellow). Template is injected with these variables: =over 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 =back =item B<-T | --token> I personal access token to access the GitHub API =item B<-U | --url> I GraphQL API endpoint, default is I =item B<-P | --package> I package name to manage versions of supported packages are: =item B<--package-regex> I regex to exclude package version name from been processed =over api app scheduler =back =item B<-N | --rows-number> I number of rows for reply pagination, max 100 (default 100) =item B<-C | --colored> to use terminal colors in output =item B<-D | --delete> if set, then all versions selected are to be deleted, if option I<-v> is set, then the only one single version is to be deleted (the one, set with I<-v>) =item B<-s | --single-run> process only first page of rows =item B<-v | --package-version> package version to manipulate with =item B<--versions-to-hold> minimum number of versions to hold (default: 2) =item B<-V | --version> version information =item B<-d | --debug> be verbose =item B<-h | --help> help message =back =head1 EXAMPLE =over 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 '.*' =back =head1 TEMPLATES Templates are .tt files. Please refer to B documentation. See examples in distribution directory I 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 } } } } } } =head1 SEE ALSO L =head1 AUTHOR Zeus Panchenko =head1 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 . =cut