itamae-plugin-recipe-anyenv 0.3.19 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/itamae/plugin/recipe/anyenv.rb +95 -89
 - data/lib/itamae/plugin/recipe/anyenv/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 00c756477a358241cb08eb1220a52e132007fdf5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5595642e770855bca517d3c519f389ce45c1a47b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d30abd2e1047b3baafd35ece27ff6a29c811297738e00d7f4afc697dccc40300d5b44a83b4d69378c695abb59c2632365e3253b97ba0a36cd988f0a97fa36e8b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5da9731bdfeb1b995b4bf19f2c8dcc76692d28a897784705c9e5e911111bc11207008ccd39ee9cdd789a5275b7d031ace9df8dddbcf5a7a6f18289e6c4462d4b
         
     | 
| 
         @@ -1,57 +1,65 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            DEFAULT_ANYENV_ROOT = '/usr/local/anyenv'.freeze
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            def run(attributes, username =  
     | 
| 
       4 
     | 
    
         
            -
              init(username)
         
     | 
| 
      
 3 
     | 
    
         
            +
            def run(attributes, username = ENV['USER'])
         
     | 
| 
      
 4 
     | 
    
         
            +
              # init(username)
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
               
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 6 
     | 
    
         
            +
              p :USR
         
     | 
| 
      
 7 
     | 
    
         
            +
              p ENV['USER']
         
     | 
| 
      
 8 
     | 
    
         
            +
              p :ANYENV_ROOT
         
     | 
| 
      
 9 
     | 
    
         
            +
              p ENV['ANYENV_ROOT']
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
       10 
     | 
    
         
            -
            end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            private
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            def init(username)
         
     | 
| 
       15 
     | 
    
         
            -
              @username = username
         
     | 
| 
       16 
     | 
    
         
            -
              @anyenv_root_path = anyenv_root(username)
         
     | 
| 
       17 
     | 
    
         
            -
              @init_cmd = anyenv_init(@anyenv_root_path)
         
     | 
| 
       18 
     | 
    
         
            -
            end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            def scheme
         
     | 
| 
       21 
     | 
    
         
            -
              @scheme ||= node[:anyenv][:scheme] || 'git'
         
     | 
| 
       22 
     | 
    
         
            -
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
              root_path = ENV['ANYENV_ROOT'] || DEFAULT_ANYENV_ROOT
         
     | 
| 
       23 
12 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
               
     | 
| 
       26 
     | 
    
         
            -
              anyenv_user_root(username)
         
     | 
| 
       27 
     | 
    
         
            -
            end
         
     | 
| 
      
 13 
     | 
    
         
            +
              clone_anyenv(root_path)
         
     | 
| 
      
 14 
     | 
    
         
            +
              clone_anyenv_update(root_path)
         
     | 
| 
       28 
15 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
               
     | 
| 
       31 
     | 
    
         
            -
                return node[:anyenv][:anyenv_root]
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
              return ENV['ANYENV_ROOT'] || DEFAULT_ANYENV_ROOT
         
     | 
| 
      
 16 
     | 
    
         
            +
              directory "#{root_path}/envs"
         
     | 
| 
      
 17 
     | 
    
         
            +
              # install_envs(attributes)
         
     | 
| 
       34 
18 
     | 
    
         
             
            end
         
     | 
| 
       35 
19 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
              if node[:anyenv][:users][username].key?(:anyenv_root)
         
     | 
| 
       38 
     | 
    
         
            -
                return node[:anyenv][:users][username][:anyenv_root]
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
              case node[:platform]
         
     | 
| 
       41 
     | 
    
         
            -
              when 'darwin'
         
     | 
| 
       42 
     | 
    
         
            -
                "/Users/#{username}/.anyenv"
         
     | 
| 
       43 
     | 
    
         
            -
              else
         
     | 
| 
       44 
     | 
    
         
            -
                "/home/#{username}/.anyenv"
         
     | 
| 
       45 
     | 
    
         
            -
              end
         
     | 
| 
       46 
     | 
    
         
            -
            end
         
     | 
| 
      
 20 
     | 
    
         
            +
            private
         
     | 
| 
       47 
21 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
            def  
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            # def init(username)
         
     | 
| 
      
 23 
     | 
    
         
            +
            #   @username = username
         
     | 
| 
      
 24 
     | 
    
         
            +
            #   @anyenv_root_path = anyenv_root(username)
         
     | 
| 
      
 25 
     | 
    
         
            +
            #   @init_cmd = anyenv_init(@anyenv_root_path)
         
     | 
| 
      
 26 
     | 
    
         
            +
            # end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            # def scheme
         
     | 
| 
      
 29 
     | 
    
         
            +
            #   @scheme ||= node[:anyenv][:scheme] || 'git'
         
     | 
| 
      
 30 
     | 
    
         
            +
            # end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            # def anyenv_root(username)
         
     | 
| 
      
 33 
     | 
    
         
            +
            #   return anyenv_system_root if username.nil?
         
     | 
| 
      
 34 
     | 
    
         
            +
            #   anyenv_user_root(username)
         
     | 
| 
      
 35 
     | 
    
         
            +
            # end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            # def anyenv_system_root
         
     | 
| 
      
 38 
     | 
    
         
            +
            #   if node[:anyenv] && node[:anyenv][:anyenv_root]
         
     | 
| 
      
 39 
     | 
    
         
            +
            #     return node[:anyenv][:anyenv_root]
         
     | 
| 
      
 40 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 41 
     | 
    
         
            +
            #   return ENV['ANYENV_ROOT'] || DEFAULT_ANYENV_ROOT
         
     | 
| 
      
 42 
     | 
    
         
            +
            # end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            # def anyenv_user_root(username)
         
     | 
| 
      
 45 
     | 
    
         
            +
            #   if node[:anyenv][:users][username].key?(:anyenv_root)
         
     | 
| 
      
 46 
     | 
    
         
            +
            #     return node[:anyenv][:users][username][:anyenv_root]
         
     | 
| 
      
 47 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 48 
     | 
    
         
            +
            #   case node[:platform]
         
     | 
| 
      
 49 
     | 
    
         
            +
            #   when 'darwin'
         
     | 
| 
      
 50 
     | 
    
         
            +
            #     "/Users/#{username}/.anyenv"
         
     | 
| 
      
 51 
     | 
    
         
            +
            #   else
         
     | 
| 
      
 52 
     | 
    
         
            +
            #     "/home/#{username}/.anyenv"
         
     | 
| 
      
 53 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 54 
     | 
    
         
            +
            # end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            # def anyenv_init(root_path)
         
     | 
| 
      
 57 
     | 
    
         
            +
            #   <<-"EOS".gsub("\n", ' ')
         
     | 
| 
      
 58 
     | 
    
         
            +
            # export ANYENV_ROOT=#{root_path};
         
     | 
| 
      
 59 
     | 
    
         
            +
            # export PATH=#{root_path}/bin:${PATH};
         
     | 
| 
      
 60 
     | 
    
         
            +
            # eval "$(anyenv init -)";
         
     | 
| 
      
 61 
     | 
    
         
            +
            #   EOS
         
     | 
| 
      
 62 
     | 
    
         
            +
            # end
         
     | 
| 
       55 
63 
     | 
    
         | 
| 
       56 
64 
     | 
    
         
             
            def clone_repository(install_path, repo_path)
         
     | 
| 
       57 
65 
     | 
    
         
             
              git install_path do
         
     | 
| 
         @@ -59,57 +67,55 @@ def clone_repository(install_path, repo_path) 
     | 
|
| 
       59 
67 
     | 
    
         
             
                repository repo_path if repo_path
         
     | 
| 
       60 
68 
     | 
    
         
             
                not_if "test -d #{install_path}"
         
     | 
| 
       61 
69 
     | 
    
         
             
              end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
              directory "#{@anyenv_root_path}/envs"
         
     | 
| 
       64 
70 
     | 
    
         
             
            end
         
     | 
| 
       65 
71 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
            def clone_anyenv
         
     | 
| 
      
 72 
     | 
    
         
            +
            def clone_anyenv(root_path)
         
     | 
| 
       67 
73 
     | 
    
         
             
              repo_path = "#{scheme}://github.com/riywo/anyenv.git"
         
     | 
| 
       68 
     | 
    
         
            -
              clone_repository( 
     | 
| 
      
 74 
     | 
    
         
            +
              clone_repository(root_path, repo_path)
         
     | 
| 
       69 
75 
     | 
    
         
             
            end
         
     | 
| 
       70 
76 
     | 
    
         | 
| 
       71 
77 
     | 
    
         
             
            def clone_anyenv_update
         
     | 
| 
       72 
     | 
    
         
            -
              install_path = "#{ 
     | 
| 
      
 78 
     | 
    
         
            +
              install_path = "#{root_path}/plugins/anyenv-update"
         
     | 
| 
       73 
79 
     | 
    
         
             
              repo_path = "#{scheme}://github.com/znz/anyenv-update.git"
         
     | 
| 
       74 
80 
     | 
    
         
             
              clone_repository(install_path, repo_path)
         
     | 
| 
       75 
81 
     | 
    
         
             
            end
         
     | 
| 
       76 
82 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
            def install_envs(attributes)
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            end
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
            def install_env(envname)
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
            end
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
            def install_env_version(envname, version)
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
            end
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
            def global_version(envname, version)
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
            end
         
     | 
| 
      
 83 
     | 
    
         
            +
            # def install_envs(attributes)
         
     | 
| 
      
 84 
     | 
    
         
            +
            #   attributes[:install_versions].each do |envs|
         
     | 
| 
      
 85 
     | 
    
         
            +
            #     envs.each do |env, vers|
         
     | 
| 
      
 86 
     | 
    
         
            +
            #       install_env(env)
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            #       vers.each do |ver|
         
     | 
| 
      
 89 
     | 
    
         
            +
            #         install_env_version(env, ver)
         
     | 
| 
      
 90 
     | 
    
         
            +
            #       end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            #       global_version(env, vers.first)
         
     | 
| 
      
 93 
     | 
    
         
            +
            #     end
         
     | 
| 
      
 94 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 95 
     | 
    
         
            +
            # end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
            # def install_env(envname)
         
     | 
| 
      
 98 
     | 
    
         
            +
            #   execute "install #{envname}" do
         
     | 
| 
      
 99 
     | 
    
         
            +
            #     user @username if @username
         
     | 
| 
      
 100 
     | 
    
         
            +
            #     command @init_cmd
         
     | 
| 
      
 101 
     | 
    
         
            +
            #     command "#{@init_cmd} yes | anyenv install #{envname};"
         
     | 
| 
      
 102 
     | 
    
         
            +
            #     not_if "type #{envname}"
         
     | 
| 
      
 103 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 104 
     | 
    
         
            +
            # end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
            # def install_env_version(envname, version)
         
     | 
| 
      
 107 
     | 
    
         
            +
            #   execute "#{envname} install #{version}" do
         
     | 
| 
      
 108 
     | 
    
         
            +
            #     user @username if @username
         
     | 
| 
      
 109 
     | 
    
         
            +
            #     command "#{@init_cmd} yes | #{envname} install #{version}"
         
     | 
| 
      
 110 
     | 
    
         
            +
            #     not_if "#{@init_cmd} #{envname} versions | grep #{version}"
         
     | 
| 
      
 111 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 112 
     | 
    
         
            +
            # end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            # def global_version(envname, version)
         
     | 
| 
      
 115 
     | 
    
         
            +
            #   execute "#{envname} global #{version}" do
         
     | 
| 
      
 116 
     | 
    
         
            +
            #     user @username if @username
         
     | 
| 
      
 117 
     | 
    
         
            +
            #     command "#{@init_cmd} #{envname} global #{version}; " \
         
     | 
| 
      
 118 
     | 
    
         
            +
            #       "#{@init_cmd} #{envname} rehash"
         
     | 
| 
      
 119 
     | 
    
         
            +
            #     not_if "#{@init_cmd} #{envname} global | grep #{version}"
         
     | 
| 
      
 120 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 121 
     | 
    
         
            +
            # end
         
     |