Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,39 @@ PATH
remote: .
specs:
serverkit-mise (0.1.0)
serverkit

GEM
remote: https://rubygems.org/
specs:
activemodel (8.0.2)
activesupport (= 8.0.2)
activesupport (8.0.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
concurrent-ruby (1.3.5)
connection_pool (2.5.1)
date (3.4.1)
drb (2.2.1)
hashie (5.0.0)
highline (3.1.2)
reline
i18n (1.14.7)
concurrent-ruby (~> 1.0)
io-console (0.8.0)
irb (1.15.2)
pp (>= 0.6.0)
Expand All @@ -16,7 +43,12 @@ GEM
json (2.10.2)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
logger (1.7.0)
minitest (5.25.5)
net-scp (4.1.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-ssh (7.3.0)
net-telnet (0.2.0)
parallel (1.27.0)
parser (3.3.8.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -55,6 +87,25 @@ GEM
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (1.13.0)
securerandom (0.4.1)
serverkit (0.9.0)
activemodel
activesupport (>= 5.0.0)
bundler
hashie
highline
rainbow
slop (~> 3.4)
specinfra (>= 2.31.0)
unix-crypt
sfl (2.3)
slop (3.6.0)
specinfra (2.93.0)
base64
net-scp
net-ssh (>= 2.7)
net-telnet
sfl
standard (1.49.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
Expand All @@ -68,9 +119,13 @@ GEM
lint_roller (~> 1.1)
rubocop-performance (~> 1.25.0)
stringio (3.1.6)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
unix-crypt (1.3.1)
uri (1.0.3)

PLATFORMS
arm64-darwin-24
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,27 @@ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG

TODO: Write usage instructions here

## Development
## Resource

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
### mise_install

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).
Install specified tool via mise.

#### Attributes

- `name` - tool name (required)
- `version` - tool version (optional)

#### Example

```yaml
resources:
- type: mise_install
name: go
- type: mise_install
name: ruby
version: 3.4.3
```

## Contributing

Expand Down
8 changes: 1 addition & 7 deletions lib/serverkit/mise.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# frozen_string_literal: true

require_relative "mise/version"

module Serverkit
module Mise
class Error < StandardError; end
# Your code goes here...
end
end
require_relative "resources/mise_install"
43 changes: 43 additions & 0 deletions lib/serverkit/resources/mise_install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

require "serverkit/resources/base"

module Serverkit
module Resources
class MiseInstall < Base
attribute :name, required: true, type: String
attribute :version, type: String

# @note Override
def apply
run_command("mise install #{name_with_version}")
end

# @note Override
def check
check_command(" mise ls #{name} | grep '#{version_or_latest}'")
end

private

# @note Override
def default_id
name
end

# @return [String]
# @example "git-plus@4.4.11"
def name_with_version
if version
"#{name}@#{version}"
else
name
end
end

def version_or_latest
version || "latest"
end
end
end
end
6 changes: 1 addition & 5 deletions serverkit-mise.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,5 @@ Gem::Specification.new do |spec|
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
spec.add_dependency "serverkit"
end