From a58264dbc7fd346400017e3ab5a278d5feb7a9cd Mon Sep 17 00:00:00 2001 From: Nuri Yuri Date: Wed, 12 Nov 2025 11:27:35 +0100 Subject: [PATCH 1/4] Create RubyGem project #2 --- .github/workflows/main.yml | 29 ++++++++++++ .gitignore | 11 +++++ .rspec | 3 ++ .rubocop.yml | 9 ++++ .solargraph.yml | 25 +++++++++++ CHANGELOG.md | 5 +++ Gemfile | 15 +++++++ Gemfile.lock | 90 ++++++++++++++++++++++++++++++++++++++ README.md | 37 +++++++++++++++- Rakefile | 12 +++++ bin/console | 11 +++++ bin/setup | 8 ++++ exe/psdk-cli | 7 +++ lib/psdk/cli.rb | 21 +++++++++ lib/psdk/cli/version.rb | 7 +++ psdk-cli.gemspec | 39 +++++++++++++++++ sig/psdk/cli.rbs | 6 +++ spec/psdk/cli_spec.rb | 7 +++ spec/spec_helper.rb | 15 +++++++ 19 files changed, 355 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 .gitignore create mode 100644 .rspec create mode 100644 .rubocop.yml create mode 100644 .solargraph.yml create mode 100644 CHANGELOG.md create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100755 bin/console create mode 100755 bin/setup create mode 100755 exe/psdk-cli create mode 100644 lib/psdk/cli.rb create mode 100644 lib/psdk/cli/version.rb create mode 100644 psdk-cli.gemspec create mode 100644 sig/psdk/cli.rbs create mode 100644 spec/psdk/cli_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f1a0e7f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: Ruby + +on: + push: + branches: + - main + + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + name: Ruby ${{ matrix.ruby }} + strategy: + matrix: + ruby: + - '3.4.5' + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run the default task + run: bundle exec rake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b04a8c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +/.bundle/ +/.yardoc +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ + +# rspec failure tracking +.rspec_status diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..34c5164 --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--format documentation +--color +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..110e525 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,9 @@ +AllCops: + TargetRubyVersion: 3.2 + NewCops: enable + +Style/StringLiterals: + EnforcedStyle: single_quotes + +Style/StringLiteralsInInterpolation: + EnforcedStyle: single_quotes diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 0000000..bdb3e30 --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,25 @@ +--- +include: +- Rakefile +- Gemfile +- "*.gemspec" +- "**/*.rb" +exclude: +- spec/**/* +- test/**/* +- vendor/**/* +- ".bundle/**/*" +require: [] +domains: [] +reporters: +- rubocop +- require_not_found +formatter: + rubocop: + cops: safe + except: [] + only: [] + extra_args: [] +require_paths: [] +plugins: [] +max_files: 5000 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..97468e6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +## [Unreleased] + +## [0.1.0] - 2025-11-12 + +- Initial release diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a45fcd0 --- /dev/null +++ b/Gemfile @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +# Specify your gem's dependencies in psdk-cli.gemspec +gemspec + +gem 'irb' +gem 'rake', '~> 13.0' + +gem 'rspec', '~> 3.0' + +gem 'rubocop', '~> 1.21' + +gem 'thor', '~> 1.4.0' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..50ffa79 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,90 @@ +PATH + remote: . + specs: + psdk-cli (0.1.0) + +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.3) + date (3.5.0) + diff-lcs (1.6.2) + erb (5.1.3) + io-console (0.8.1) + irb (1.15.3) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.16.0) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + parallel (1.27.0) + parser (3.3.10.0) + ast (~> 2.4.1) + racc + pp (0.6.3) + prettyprint + prettyprint (0.2.0) + prism (1.6.0) + psych (5.2.6) + date + stringio + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.1) + rdoc (6.15.1) + erb + psych (>= 4.0.0) + tsort + regexp_parser (2.11.3) + reline (0.6.3) + io-console (~> 0.5) + rspec (3.13.2) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.7) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.6) + rubocop (1.81.7) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.47.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.48.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) + stringio (3.1.8) + thor (1.4.0) + tsort (0.2.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + +PLATFORMS + arm64-darwin-24 + ruby + +DEPENDENCIES + irb + psdk-cli! + rake (~> 13.0) + rspec (~> 3.0) + rubocop (~> 1.21) + thor (~> 1.4.0) + +BUNDLED WITH + 2.7.2 diff --git a/README.md b/README.md index 1217abf..9cceb58 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ -# psdk-cli -A CLI that helps people perform actions with PSDK +# Psdk::Cli + +TODO: Delete this and the text below, and describe your gem + +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/psdk/cli`. To experiment with that code, run `bin/console` for an interactive prompt. + +## Installation + +TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. + +Install the gem and add to the application's Gemfile by executing: + +```bash +bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG +``` + +If bundler is not being used to manage dependencies, install the gem by executing: + +```bash +gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG +``` + +## Usage + +TODO: Write usage instructions here + +## Development + +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/psdk-cli. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..4964751 --- /dev/null +++ b/Rakefile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) + +require 'rubocop/rake_task' + +RuboCop::RakeTask.new + +task default: %i[spec rubocop] diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..b47120f --- /dev/null +++ b/bin/console @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'bundler/setup' +require 'psdk/cli' + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +require 'irb' +IRB.start(__FILE__) diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/exe/psdk-cli b/exe/psdk-cli new file mode 100755 index 0000000..c106047 --- /dev/null +++ b/exe/psdk-cli @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'bundler/setup' +require 'psdk/cli' + +Psdk::Cli::Main.start diff --git a/lib/psdk/cli.rb b/lib/psdk/cli.rb new file mode 100644 index 0000000..8b933e3 --- /dev/null +++ b/lib/psdk/cli.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'thor' + +module Psdk + module Cli + # Main PSDK CLI class + # + # Must be used for the general psdk-cli command + class Main < Thor + package_name 'psdk-cli' + + desc('version', 'show the psdk-cli version') + def version + puts "psdk-cli v#{VERSION}" + end + end + end +end + +require_relative 'cli/version' diff --git a/lib/psdk/cli/version.rb b/lib/psdk/cli/version.rb new file mode 100644 index 0000000..16ac99e --- /dev/null +++ b/lib/psdk/cli/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Psdk + module Cli + VERSION = '0.1.0' + end +end diff --git a/psdk-cli.gemspec b/psdk-cli.gemspec new file mode 100644 index 0000000..b111fdb --- /dev/null +++ b/psdk-cli.gemspec @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative 'lib/psdk/cli/version' + +Gem::Specification.new do |spec| + spec.name = 'psdk-cli' + spec.version = Psdk::Cli::VERSION + spec.authors = ['Pokémon Workshop'] + spec.email = ['hostmaster@pokemonworkshop.com'] + + spec.summary = 'Utility cli that would help people perform several actions related to PSDK.' + spec.homepage = 'https://github.com/PokemonWorkshop/psdk-cli' + spec.required_ruby_version = '>= 3.2.0' + + # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" + spec.metadata['homepage_uri'] = spec.homepage + spec.metadata['source_code_uri'] = 'https://github.com/PokemonWorkshop/psdk-cli' + spec.metadata['changelog_uri'] = 'https://github.com/PokemonWorkshop/psdk-cli/blob/main/CHANGELOG.md' + spec.metadata['rubygems_mfa_required'] = 'true' + + # Specify which files should be added to the gem when it is released. + # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + gemspec = File.basename(__FILE__) + spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls| + ls.readlines("\x0", chomp: true).reject do |f| + (f == gemspec) || + f.start_with?(*%w[bin/ Gemfile .gitignore .rspec spec/ .github/ .rubocop.yml]) + end + end + spec.bindir = 'exe' + spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } + spec.require_paths = ['lib'] + + # Uncomment to register a new dependency of your gem + # spec.add_dependency "example-gem", "~> 1.0" + + # For more information and examples about making a new gem, check out our + # guide at: https://bundler.io/guides/creating_gem.html +end diff --git a/sig/psdk/cli.rbs b/sig/psdk/cli.rbs new file mode 100644 index 0000000..75fe532 --- /dev/null +++ b/sig/psdk/cli.rbs @@ -0,0 +1,6 @@ +module Psdk + module Cli + VERSION: String + # See the writing guide of rbs: https://github.com/ruby/rbs#guides + end +end diff --git a/spec/psdk/cli_spec.rb b/spec/psdk/cli_spec.rb new file mode 100644 index 0000000..d971b33 --- /dev/null +++ b/spec/psdk/cli_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +RSpec.describe Psdk::Cli do + it 'has a version number' do + expect(Psdk::Cli::VERSION).not_to be nil + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..56fb1cf --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'psdk/cli' + +RSpec.configure do |config| + # Enable flags like --only-failures and --next-failure + config.example_status_persistence_file_path = '.rspec_status' + + # Disable RSpec exposing methods globally on `Module` and `main` + config.disable_monkey_patching! + + config.expect_with :rspec do |c| + c.syntax = :expect + end +end From 9df8e1c09e4d26136600ca99202cf4d23fbf754b Mon Sep 17 00:00:00 2001 From: Nuri Yuri Date: Wed, 12 Nov 2025 11:35:40 +0100 Subject: [PATCH 2/4] Add support for sub commands --- exe/psdk-plugin | 7 +++++++ lib/psdk/cli.rb | 7 +++++-- lib/psdk/cli/plugin.rb | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 exe/psdk-plugin create mode 100644 lib/psdk/cli/plugin.rb diff --git a/exe/psdk-plugin b/exe/psdk-plugin new file mode 100755 index 0000000..c38a552 --- /dev/null +++ b/exe/psdk-plugin @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'bundler/setup' +require 'psdk/cli/plugin' + +Psdk::Cli::Plugin.start diff --git a/lib/psdk/cli.rb b/lib/psdk/cli.rb index 8b933e3..0e05783 100644 --- a/lib/psdk/cli.rb +++ b/lib/psdk/cli.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require 'thor' +require_relative 'cli/version' +require_relative 'cli/plugin' module Psdk module Cli @@ -14,8 +16,9 @@ class Main < Thor def version puts "psdk-cli v#{VERSION}" end + + desc 'plugin', 'manage PSDK plugins' + subcommand 'plugin', Plugin end end end - -require_relative 'cli/version' diff --git a/lib/psdk/cli/plugin.rb b/lib/psdk/cli/plugin.rb new file mode 100644 index 0000000..cade952 --- /dev/null +++ b/lib/psdk/cli/plugin.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'thor' + +module Psdk + module Cli + # Class responsible of handling the psdk-plugin cli commands + class Plugin < Thor + package_name 'psdk-plugin' + + # TODO: remove this and actually implement the plugin cli + desc 'fake ARG1', 'run a fake command with ARG1 as first argument' + def fake(arg1) + puts "Fake called with ARG1=#{arg1}" + end + end + end +end From 5b7841ca288eef8d03ecc34b1039c507010b17f2 Mon Sep 17 00:00:00 2001 From: Nuri Yuri Date: Wed, 12 Nov 2025 11:41:28 +0100 Subject: [PATCH 3/4] Update readme --- README.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9cceb58..2c524e3 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,20 @@ -# Psdk::Cli +# psdk-cli -TODO: Delete this and the text below, and describe your gem - -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/psdk/cli`. To experiment with that code, run `bin/console` for an interactive prompt. +A CLI that helps people perform actions with PSDK ## Installation -TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. - -Install the gem and add to the application's Gemfile by executing: +To be able to use the psdk-cli you must install Ruby and Git and then run the following command: ```bash -bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG -``` - -If bundler is not being used to manage dependencies, install the gem by executing: - -```bash -gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG +gem install psdk-cli ``` ## Usage -TODO: Write usage instructions here +In a terminal you can run `psdk-cli` it will list all the available commands. + +Please note that sub command (such as `psdk-cli plugin`) can be executed using the shortcut `psdk-` (eg. `psdk-plugin` for `psdk-cli plugin`). ## Development @@ -32,4 +24,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/psdk-cli. +Bug reports and pull requests are welcome on GitHub at https://github.com/PokemonWorkshop/psdk-cli. From 7d9f6feee0aa841fd4e201a833ff38b981e6f393 Mon Sep 17 00:00:00 2001 From: Nuri Yuri Date: Thu, 13 Nov 2025 09:50:36 +0100 Subject: [PATCH 4/4] Fix styling on version desc --- lib/psdk/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/psdk/cli.rb b/lib/psdk/cli.rb index 0e05783..06e6fd1 100644 --- a/lib/psdk/cli.rb +++ b/lib/psdk/cli.rb @@ -12,7 +12,7 @@ module Cli class Main < Thor package_name 'psdk-cli' - desc('version', 'show the psdk-cli version') + desc 'version', 'show the psdk-cli version' def version puts "psdk-cli v#{VERSION}" end