From ca332f55ce57be41a3ca4b5b48a90b0dfabb0c43 Mon Sep 17 00:00:00 2001 From: toshimaru Date: Tue, 22 Apr 2025 10:16:47 +0900 Subject: [PATCH 1/7] docs: Update rdoc --- lib/serverkit/resources/mise_install.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/serverkit/resources/mise_install.rb b/lib/serverkit/resources/mise_install.rb index 2c90949..82e50e4 100644 --- a/lib/serverkit/resources/mise_install.rb +++ b/lib/serverkit/resources/mise_install.rb @@ -26,7 +26,7 @@ def default_id end # @return [String] - # @example "git-plus@4.4.11" + # @example "ruby@3.4.3" def name_with_version if version "#{name}@#{version}" @@ -35,6 +35,7 @@ def name_with_version end end + # @return [String] def version_or_latest version || "latest" end From 1b05df25fcac72ec81c5d5d54714dbcac713899d Mon Sep 17 00:00:00 2001 From: toshimaru Date: Tue, 22 Apr 2025 10:21:11 +0900 Subject: [PATCH 2/7] doc: Update badge and description --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 371e1d3..c3586f4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ -[![Ruby](https://github.com/serverkit/serverkit-mise/actions/workflows/main.yml/badge.svg)](https://github.com/serverkit/serverkit-mise/actions/workflows/main.yml) +[![Test](https://github.com/serverkit/serverkit-mise/actions/workflows/test.yml/badge.svg)](https://github.com/serverkit/serverkit-mise/actions/workflows/test.yml) -# Serverkit::Mise +# serverkit-mise -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/serverkit/mise`. To experiment with that code, run `bin/console` for an interactive prompt. +[Serverkit](https://github.com/serverkit/serverkit) plug-in for [mise](https://github.com/jdx/mise). ## Installation From 2ef7df79a02476fe6037f3abc521dc54b1d77bc5 Mon Sep 17 00:00:00 2001 From: toshimaru Date: Tue, 22 Apr 2025 10:21:56 +0900 Subject: [PATCH 3/7] feat: Add `type: mise_use` ``` - type: mise_use name: go - type: mise_use name: ruby version: 3.4.3 ``` --- lib/serverkit/mise.rb | 1 + lib/serverkit/resources/mise_use.rb | 43 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 lib/serverkit/resources/mise_use.rb diff --git a/lib/serverkit/mise.rb b/lib/serverkit/mise.rb index a78f63b..e1c8681 100644 --- a/lib/serverkit/mise.rb +++ b/lib/serverkit/mise.rb @@ -2,3 +2,4 @@ require_relative "mise/version" require_relative "resources/mise_install" +require_relative "resources/mise_use" diff --git a/lib/serverkit/resources/mise_use.rb b/lib/serverkit/resources/mise_use.rb new file mode 100644 index 0000000..6c6824e --- /dev/null +++ b/lib/serverkit/resources/mise_use.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require "serverkit/resources/base" + +module Serverkit + module Resources + class MiseUse < Base + attribute :name, required: true, type: String + attribute :version, type: String + + # @note Override + def apply + run_command("mise use #{name_with_version}") + end + + # @note Override + def check + check_command(" mise ls --current #{name} | grep '#{version_or_latest}'") + end + + private + + # @note Override + def default_id + name + end + + # @return [String] + # @example "ruby@3.4.3" + def name_with_version + if version + "#{name}@#{version}" + else + name + end + end + + def version_or_latest + version || "latest" + end + end + end +end From f7620c9a754612e74a9dd87a2d942eff13d7c111 Mon Sep 17 00:00:00 2001 From: toshimaru Date: Tue, 22 Apr 2025 10:28:41 +0900 Subject: [PATCH 4/7] ci: CI against Ruby 3.4 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2a68e57..60c1d9f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - ruby: ["3.1", "3.2", "3.3", "3.3"] + ruby: ["3.1", "3.2", "3.3", "3.4"] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From 18b83038c64971fcbcf642933414bd69c8e7385f Mon Sep 17 00:00:00 2001 From: toshimaru Date: Wed, 23 Apr 2025 15:45:32 +0900 Subject: [PATCH 5/7] WIP: Adding global option --- lib/serverkit/resources/mise_use.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/serverkit/resources/mise_use.rb b/lib/serverkit/resources/mise_use.rb index 6c6824e..ff51cdd 100644 --- a/lib/serverkit/resources/mise_use.rb +++ b/lib/serverkit/resources/mise_use.rb @@ -7,15 +7,22 @@ module Resources class MiseUse < Base attribute :name, required: true, type: String attribute :version, type: String + # FIXME: add global option + attribute :global, type: [TrueClass, FalseClass] # , default: true # @note Override def apply - run_command("mise use #{name_with_version}") + run_command("mise use --global #{name_with_version}") end # @note Override def check - check_command(" mise ls --current #{name} | grep '#{version_or_latest}'") + cmd = if global + "mise ls --global #{name} | grep '#{version_or_latest}'" + else + "mise ls --current #{name} | grep '#{version_or_latest}'" + end + check_command(cmd) end private @@ -38,6 +45,10 @@ def name_with_version def version_or_latest version || "latest" end + + # def global_option + # "--global" if global + # end end end end From 97ab32bc7d3c2b06f41faab7ae3e4f55bfbae77f Mon Sep 17 00:00:00 2001 From: toshimaru Date: Wed, 23 Apr 2025 15:56:17 +0900 Subject: [PATCH 6/7] docs: `mise_use` --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index c3586f4..722dab8 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,26 @@ resources: version: 3.4.3 ``` +### mise_use + +Install specified tool and add the version to `mise.yml`. + +#### Attributes + +- `name` - tool name (required) +- `version` - tool version (optional) + +#### Example + +```yaml +resources: + - type: mise_use + name: go + version: '1.23' + - type: mise_use + name: ruby +``` + ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/serverkit-mise. From 74057b96d988b673fa367502949cbbad1e0289e7 Mon Sep 17 00:00:00 2001 From: toshimaru Date: Wed, 23 Apr 2025 16:06:51 +0900 Subject: [PATCH 7/7] docs: Update placeholder text --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 722dab8..3526922 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,18 @@ ## 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. +TODO: Replace `serverkit-mise` 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 +bundle add serverkit-mise ``` 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 serverkit-mise ``` ## Usage @@ -68,7 +68,7 @@ resources: ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/serverkit-mise. +Bug reports and pull requests are welcome on GitHub at [serverkit/serverkit-mise](https://github.com/serverkit/serverkit-mise). ## License