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..2c524e3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,27 @@ # psdk-cli + A CLI that helps people perform actions with PSDK + +## Installation + +To be able to use the psdk-cli you must install Ruby and Git and then run the following command: + +```bash +gem install psdk-cli +``` + +## Usage + +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 + +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/PokemonWorkshop/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/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 new file mode 100644 index 0000000..06e6fd1 --- /dev/null +++ b/lib/psdk/cli.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'thor' +require_relative 'cli/version' +require_relative 'cli/plugin' + +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 + + desc 'plugin', 'manage PSDK plugins' + subcommand 'plugin', Plugin + end + end +end 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 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