Skip to content

Commit

Permalink
Implementing a Thor CLI task for managing RubyGems Gem administration
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii committed May 25, 2022
1 parent 13eef60 commit 47c73bf
Show file tree
Hide file tree
Showing 18 changed files with 1,243 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Gemfile.lock
.yardoc
coverage
doc
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
35 changes: 35 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
AllCops:
Exclude:
- 'script/**/*'

Layout/LineLength:
Exclude:
- 'lib/samvera/git_hub.rb'
- 'lib/samvera/org.rb'
- 'spec/system/cli_spec.rb'

Metrics/AbcSize:
Exclude:
- 'lib/samvera/gem_query_service.rb'
- 'lib/samvera/org.rb'

Metrics/BlockLength:
Exclude:
- 'Rakefile'
- 'lib/samvera/gem_query_service.rb'
- 'spec/system/cli_spec.rb'

Metrics/MethodLength:
Exclude:
- 'lib/samvera/gem_query_service.rb'
- 'lib/samvera/org.rb'

Style/Documentation:
Exclude:
- 'lib/samvera.rb'
- 'lib/samvera/gem_query_service.rb'
- 'lib/samvera/git_hub.rb'
- 'lib/samvera/org.rb'
- 'lib/samvera/repository_query_service.rb'
- 'lib/samvera/ruby_gems.rb'

63 changes: 63 additions & 0 deletions CLI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Component Maintenance Interest Group
## Command-Line Interface (CLI) Utility

### Getting Started

1. Get a personal access token from GitHub (https://github.com/settings/tokens) with the following scopes enabled:
* `public_repo`
* `read:org`
* `user:email`
1. Set an ENV variable named `GITHUB_SAMVERA_TOKEN` containing your token

The CLI commands may then be listed using the following:

```bash
$ bundle exec thor list
```

...yielding:

```bash
samvera
-------
thor samvera:org:add_owners # Ensure that all members of the administrator GitHub Team are Gem Owners for RubyGems entries
thor samvera:org:admins # list members of the GitHub administrative Team
thor samvera:org:contributors # list members of the GitHub administrative Team
thor samvera:org:remove_owners # Ensure that all Gem Owners for RubyGems entries which are *not* members of the administrator ...
thor samvera:org:repositories # list Samvera repositories
```

### Queries

One may retrieve the current GitHub administrators using the following:

```bash
$ bundle exec thor samvera:org:admins
```

One may retrieve the current GitHub contributors using the following:

```bash
$ bundle exec thor samvera:org:contributors
```

One may also retrieve the current GitHub repositories managing Ruby Gem projects using the following:

```bash
$ bundle exec thor samvera:org:repositories
```

### Gem Management

As an administrator, one may grant ownership privileges for RubyGems entries to all GitHub contributors using the following:

```bash
$ bundle exec thor samvera:org:add_owners
```

As an administrator, one may revoke ownership privileges for RubyGems entries to owners who are neither GitHub contributors nor GitHub administrators using the following:

```bash
$ bundle exec thor samvera:org:remove_owners
```

15 changes: 14 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'github_api'
gem 'huborg'
gem 'rake'
gem 'rake'
gem 'thor'

group :development do
gem 'bixby'
gem 'pry-byebug'
gem 'rspec'
gem 'simplecov'
gem 'webmock'
gem 'yard'
end
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ This template is something to push to all samvera repositories. The goal in
applying a common mailmap is to help understand contributions as people move
and change roles/functions/laptops.

## Command-Line Interface (CLI) Utility

There exists a command-line interface utility which may be used to query for GitHub Team data and in order to perform RubyGems administrative tasks. [Please reference the CLI documentation for an overview of the usage for this](./CLI.md).

## Ruby Scripts

There exist Ruby scripts in this repository that can be used to propagate some of these templates:
Expand Down
20 changes: 11 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
# frozen_string_literal: true

namespace :templates do
desc "Push CODE_OF_CONDUCT.md to all repositories, this requires ENV['GITHUB_ACCESS_TOKEN']"
task :code_of_conduct do
require 'huborg'
client = Huborg::Client.new(org_names: ["samvera", "samvera-labs"])
client = Huborg::Client.new(org_names: %w[samvera samvera-labs])
client.push_template!(
template: File.expand_path("./templates/CODE_OF_CONDUCT.md"),
filename: "CODE_OF_CONDUCT.md",
template: File.expand_path('./templates/CODE_OF_CONDUCT.md'),
filename: 'CODE_OF_CONDUCT.md',
overwrite: true
)
end
desc "Push CONTRIBUTING.md to all repositories, this requires ENV['GITHUB_ACCESS_TOKEN']"
task :contributing do
require 'huborg'
client = Huborg::Client.new(org_names: ["samvera", "samvera-labs"])
client = Huborg::Client.new(org_names: %w[samvera samvera-labs])
client.push_template!(
template: File.expand_path("./templates/CONTRIBUTING.md"),
filename: "CONTRIBUTING.md",
template: File.expand_path('./templates/CONTRIBUTING.md'),
filename: 'CONTRIBUTING.md',
overwrite: true
)
end
desc "Push SUPPORT.md to all repositories, this requires ENV['GITHUB_ACCESS_TOKEN']"
task :support do
require 'huborg'
client = Huborg::Client.new(org_names: ["samvera", "samvera-labs"])
client = Huborg::Client.new(org_names: %w[samvera samvera-labs])
client.push_template!(
template: File.expand_path("./templates/SUPPORT.md"),
filename: "SUPPORT.md",
template: File.expand_path('./templates/SUPPORT.md'),
filename: 'SUPPORT.md',
overwrite: true
)
end
Expand Down
5 changes: 5 additions & 0 deletions cli.thor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require_relative 'lib/samvera'

Samvera::Org.new
89 changes: 89 additions & 0 deletions config/github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
rubygems:
gems:
# [GitHub Repository]: [RubyGems Gem]
active_fedora: active-fedora
fcrepo-admin: fcrepo_admin
questioning_authority: qa
repositories:
invalid:
# samvera
- cla-bot
- cla-bot-old
- hyku
- maintenance
- samvera-circleci-orb
- samvera.github.io
# samvera-labs
- ActiveTriples
- starter-react-component-npm
- stencil-test-components
- sufia.io
- samvera-connect
- samvera-labs.github.io
- samvera-persona
- samvera-virtual-connect
- samvera.org
- samvera_docs
- serverless-iiif
- sessionizer
- uri_selection_wg
- ValkyrieAPI
- repository_utils
- power-steering
- openseadragon-react-viewer
- nurax-pg
- node-iiif
- nectar-iiif
- browse-everything-components
- browse-everything-redux-react
- iiif-image-api
- iiif-react-media-player
- hyku-api
- hyku.github.io
- docker-fcrepo
- fcrepo-charts
- fcrepo3
- fcrepo3-ldp
- core-dependency-report
- digital_collections_elixir_example
- branch-renaming-wg
- bloom-iiif
- AdvancingHyku
- ansible-sufia7-playbook
- clover-iiif
- houndstooth
- image-downloader
- allinson_flex
- analytics_nurax
- avalon-bundle
- book_concerns
- doi_registrar
- hybox-ideas
- hydra-admin-collections
- hydra-shibboleth
- hydra_controlled_vocabularies
- hydra_documentation_wg
- hydra_file_sets_wg
- hydra_plugins_wg
- hyrax-batch_ingest..
- hyrax-google_analytics
- hyrax-hirmeos
- hyrax-json_fields
- hyrax-orcid
- hyrax-speed_test
- karmabot
- open_annotation_models
- rdf-proxy_list
- ruby-oai
- samvera-external_storage
- samvera-shibboleth
- sipity
- speedy_af
- storage_proxy_api
- valkyrie-cloud_search
- valkyrie-derivatives
- valkyrie-dynamodb
- valkyrie-redis
- valkyrie_pg_demo
- hyrax-batch_ingest
16 changes: 16 additions & 0 deletions config/rubygems.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
github:
owners:
# [GitHub Account]: [RubyGems Account]
aaron-collier: acollier
billdueber: BillDueber
carolyncole: cam156
hackartisan: HackmasterA
jrgriffiniii: jrgriffiniii
julesies: geekycoder
no-reply: no_reply
owners:
invalid:
- kelynch
- mlooney
- orangewolf
21 changes: 21 additions & 0 deletions lib/samvera.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Samvera
def self.relative_file_path
File.dirname(__FILE__)
end

def self.absolute_file_path
File.absolute_path(relative_file_path)
end

def self.root_path
Pathname.new(absolute_file_path)
end

autoload(:GemQueryService, root_path.join('samvera', 'gem_query_service'))
autoload(:RubyGems, root_path.join('samvera', 'ruby_gems'))
autoload(:RepositoryQueryService, root_path.join('samvera', 'repository_query_service'))
autoload(:GitHub, root_path.join('samvera', 'git_hub'))
autoload(:Org, root_path.join('samvera', 'org'))
end
Loading

0 comments on commit 47c73bf

Please sign in to comment.