-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module MStrap | ||
module RuntimeManagers | ||
class Mise < RuntimeManager | ||
def name : String | ||
"mise" | ||
end | ||
|
||
def current_version(language_name : String) : String? | ||
`mise current #{language_name}`.chomp | ||
end | ||
|
||
# Returns whether the mise plugin has been installed for a language runtime | ||
# or not | ||
def has_plugin?(language_name : String) : Bool | ||
`mise plugins ls --core --user`.chomp.split("\n").includes?(plugin_name(language_name)) | ||
end | ||
|
||
def install_plugin(language_name : String) : Bool | ||
cmd("mise plugins install #{plugin_name(language_name)}", quiet: true) | ||
end | ||
|
||
def install_version(language_name : String, version : String) : Bool | ||
cmd("mise install #{plugin_name(language_name)} #{version}", quiet: true) | ||
end | ||
|
||
# Returns a list of the versions of the language runtime installed | ||
# by mise. | ||
def installed_versions(language_name : String) : Array(String) | ||
mise_json_output = `mise ls -i #{plugin_name(language_name)} --json` | ||
mise_installed = JSON.parse(mise_json_output) | ||
mise_installed[language_name].as_a.map { |version| version["version"].as_s } | ||
end | ||
|
||
def latest_version(language_name : String) : String | ||
`mise latest #{plugin_name(language_name)}`.chomp | ||
end | ||
|
||
# Name of the mise plugin for a particular language | ||
def plugin_name(language_name : String) : String? | ||
language_name | ||
end | ||
|
||
def set_global_version(language_name, version : String) : Bool | ||
cmd "mise use -g #{plugin_name(language_name)}@#{version}", quiet: true | ||
end | ||
|
||
# :nodoc: | ||
def version_env_var(language_name) : String | ||
if asdf_plugin_name = plugin_name(language_name) | ||
"MISE_#{asdf_plugin_name.upcase}_VERSION" | ||
else | ||
"MISE_#{language_name.upcase}_VERSION" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env <%= shell_name %> | ||
|
||
export MSTRAP=true | ||
export MSTRAP_PROJECT_SOCKETS="<%= MStrap::Paths::PROJECT_SOCKETS %>" | ||
export MSTRAP_SRC_DIR="<%= MStrap::Paths::SRC_DIR %>" | ||
export MSTRAP_RC_DIR="<%= MStrap::Paths::RC_DIR %>" | ||
|
||
<%- if needs_homebrew_shellenv? %> | ||
# Load Homebrew | ||
test -d <%= MStrap::Paths::HOMEBREW_PREFIX %> && eval $(<%= MStrap::Paths::HOMEBREW_PREFIX %>/bin/brew shellenv) | ||
<% end -%> | ||
|
||
<% if runtime_manager.name == "asdf" %> | ||
# Activate asdf for language runtime version management | ||
if [ -d "$(brew --prefix asdf)" ]; then | ||
source "$(brew --prefix asdf)/libexec/asdf.sh" | ||
|
||
if [ ! -f "$HOME/.asdfrc" ]; then | ||
echo "legacy_version_file = yes\n" > "$HOME/.asdfrc" | ||
fi | ||
fi | ||
<% elsif runtime_manager.name == "mise" %> | ||
# Activate mise for language runtime version management | ||
export MISE_ASDF_COMPAT=1 | ||
eval "$(mise activate <%= shell_name %>)" | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters