carat 1.9.9.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +24 -0
  5. data/CHANGELOG.md +2006 -0
  6. data/CODE_OF_CONDUCT.md +40 -0
  7. data/CONTRIBUTING.md +23 -0
  8. data/DEVELOPMENT.md +119 -0
  9. data/ISSUES.md +96 -0
  10. data/LICENSE.md +23 -0
  11. data/README.md +32 -0
  12. data/Rakefile +308 -0
  13. data/bin/carat +21 -0
  14. data/bin/carat_ruby +56 -0
  15. data/carat.gemspec +32 -0
  16. data/lib/carat.rb +446 -0
  17. data/lib/carat/anonymizable_uri.rb +32 -0
  18. data/lib/carat/capistrano.rb +16 -0
  19. data/lib/carat/cli.rb +407 -0
  20. data/lib/carat/cli/binstubs.rb +38 -0
  21. data/lib/carat/cli/cache.rb +35 -0
  22. data/lib/carat/cli/check.rb +35 -0
  23. data/lib/carat/cli/clean.rb +26 -0
  24. data/lib/carat/cli/common.rb +56 -0
  25. data/lib/carat/cli/config.rb +84 -0
  26. data/lib/carat/cli/console.rb +38 -0
  27. data/lib/carat/cli/exec.rb +44 -0
  28. data/lib/carat/cli/gem.rb +195 -0
  29. data/lib/carat/cli/init.rb +33 -0
  30. data/lib/carat/cli/inject.rb +33 -0
  31. data/lib/carat/cli/install.rb +156 -0
  32. data/lib/carat/cli/open.rb +23 -0
  33. data/lib/carat/cli/outdated.rb +80 -0
  34. data/lib/carat/cli/package.rb +45 -0
  35. data/lib/carat/cli/platform.rb +43 -0
  36. data/lib/carat/cli/show.rb +74 -0
  37. data/lib/carat/cli/update.rb +73 -0
  38. data/lib/carat/cli/viz.rb +27 -0
  39. data/lib/carat/constants.rb +5 -0
  40. data/lib/carat/current_ruby.rb +183 -0
  41. data/lib/carat/definition.rb +628 -0
  42. data/lib/carat/dep_proxy.rb +43 -0
  43. data/lib/carat/dependency.rb +110 -0
  44. data/lib/carat/deployment.rb +59 -0
  45. data/lib/carat/deprecate.rb +15 -0
  46. data/lib/carat/dsl.rb +331 -0
  47. data/lib/carat/endpoint_specification.rb +76 -0
  48. data/lib/carat/env.rb +75 -0
  49. data/lib/carat/environment.rb +42 -0
  50. data/lib/carat/fetcher.rb +423 -0
  51. data/lib/carat/friendly_errors.rb +85 -0
  52. data/lib/carat/gem_helper.rb +180 -0
  53. data/lib/carat/gem_helpers.rb +26 -0
  54. data/lib/carat/gem_installer.rb +9 -0
  55. data/lib/carat/gem_path_manipulation.rb +8 -0
  56. data/lib/carat/gem_tasks.rb +2 -0
  57. data/lib/carat/graph.rb +169 -0
  58. data/lib/carat/index.rb +197 -0
  59. data/lib/carat/injector.rb +64 -0
  60. data/lib/carat/installer.rb +339 -0
  61. data/lib/carat/lazy_specification.rb +83 -0
  62. data/lib/carat/lockfile_parser.rb +167 -0
  63. data/lib/carat/match_platform.rb +13 -0
  64. data/lib/carat/psyched_yaml.rb +26 -0
  65. data/lib/carat/remote_specification.rb +57 -0
  66. data/lib/carat/resolver.rb +334 -0
  67. data/lib/carat/retry.rb +60 -0
  68. data/lib/carat/ruby_dsl.rb +11 -0
  69. data/lib/carat/ruby_version.rb +117 -0
  70. data/lib/carat/rubygems_ext.rb +170 -0
  71. data/lib/carat/rubygems_integration.rb +619 -0
  72. data/lib/carat/runtime.rb +289 -0
  73. data/lib/carat/settings.rb +208 -0
  74. data/lib/carat/setup.rb +24 -0
  75. data/lib/carat/shared_helpers.rb +149 -0
  76. data/lib/carat/similarity_detector.rb +63 -0
  77. data/lib/carat/source.rb +46 -0
  78. data/lib/carat/source/git.rb +294 -0
  79. data/lib/carat/source/git/git_proxy.rb +162 -0
  80. data/lib/carat/source/path.rb +226 -0
  81. data/lib/carat/source/path/installer.rb +43 -0
  82. data/lib/carat/source/rubygems.rb +381 -0
  83. data/lib/carat/source_list.rb +101 -0
  84. data/lib/carat/spec_set.rb +154 -0
  85. data/lib/carat/ssl_certs/.document +1 -0
  86. data/lib/carat/ssl_certs/AddTrustExternalCARoot-2048.pem +25 -0
  87. data/lib/carat/ssl_certs/AddTrustExternalCARoot.pem +32 -0
  88. data/lib/carat/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +14 -0
  89. data/lib/carat/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +23 -0
  90. data/lib/carat/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +28 -0
  91. data/lib/carat/ssl_certs/GeoTrustGlobalCA.pem +20 -0
  92. data/lib/carat/ssl_certs/certificate_manager.rb +66 -0
  93. data/lib/carat/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
  94. data/lib/carat/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
  95. data/lib/carat/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
  96. data/lib/carat/templates/Executable +16 -0
  97. data/lib/carat/templates/Executable.standalone +12 -0
  98. data/lib/carat/templates/Gemfile +4 -0
  99. data/lib/carat/templates/newgem/.travis.yml.tt +3 -0
  100. data/lib/carat/templates/newgem/CODE_OF_CONDUCT.md.tt +13 -0
  101. data/lib/carat/templates/newgem/Gemfile.tt +4 -0
  102. data/lib/carat/templates/newgem/LICENSE.txt.tt +21 -0
  103. data/lib/carat/templates/newgem/README.md.tt +39 -0
  104. data/lib/carat/templates/newgem/Rakefile.tt +25 -0
  105. data/lib/carat/templates/newgem/bin/console.tt +14 -0
  106. data/lib/carat/templates/newgem/bin/setup.tt +7 -0
  107. data/lib/carat/templates/newgem/exe/newgem.tt +3 -0
  108. data/lib/carat/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
  109. data/lib/carat/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  110. data/lib/carat/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  111. data/lib/carat/templates/newgem/gitignore.tt +16 -0
  112. data/lib/carat/templates/newgem/lib/newgem.rb.tt +12 -0
  113. data/lib/carat/templates/newgem/lib/newgem/version.rb.tt +7 -0
  114. data/lib/carat/templates/newgem/newgem.gemspec.tt +43 -0
  115. data/lib/carat/templates/newgem/rspec.tt +2 -0
  116. data/lib/carat/templates/newgem/spec/newgem_spec.rb.tt +11 -0
  117. data/lib/carat/templates/newgem/spec/spec_helper.rb.tt +2 -0
  118. data/lib/carat/templates/newgem/test/minitest_helper.rb.tt +4 -0
  119. data/lib/carat/templates/newgem/test/test_newgem.rb.tt +11 -0
  120. data/lib/carat/ui.rb +7 -0
  121. data/lib/carat/ui/rg_proxy.rb +21 -0
  122. data/lib/carat/ui/shell.rb +103 -0
  123. data/lib/carat/ui/silent.rb +44 -0
  124. data/lib/carat/vendor/molinillo/lib/molinillo.rb +5 -0
  125. data/lib/carat/vendor/molinillo/lib/molinillo/dependency_graph.rb +266 -0
  126. data/lib/carat/vendor/molinillo/lib/molinillo/errors.rb +69 -0
  127. data/lib/carat/vendor/molinillo/lib/molinillo/gem_metadata.rb +3 -0
  128. data/lib/carat/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +90 -0
  129. data/lib/carat/vendor/molinillo/lib/molinillo/modules/ui.rb +63 -0
  130. data/lib/carat/vendor/molinillo/lib/molinillo/resolution.rb +415 -0
  131. data/lib/carat/vendor/molinillo/lib/molinillo/resolver.rb +43 -0
  132. data/lib/carat/vendor/molinillo/lib/molinillo/state.rb +43 -0
  133. data/lib/carat/vendor/net/http/faster.rb +26 -0
  134. data/lib/carat/vendor/net/http/persistent.rb +1230 -0
  135. data/lib/carat/vendor/net/http/persistent/ssl_reuse.rb +128 -0
  136. data/lib/carat/vendor/thor/lib/thor.rb +484 -0
  137. data/lib/carat/vendor/thor/lib/thor/actions.rb +319 -0
  138. data/lib/carat/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  139. data/lib/carat/vendor/thor/lib/thor/actions/create_link.rb +59 -0
  140. data/lib/carat/vendor/thor/lib/thor/actions/directory.rb +118 -0
  141. data/lib/carat/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
  142. data/lib/carat/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
  143. data/lib/carat/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
  144. data/lib/carat/vendor/thor/lib/thor/base.rb +656 -0
  145. data/lib/carat/vendor/thor/lib/thor/command.rb +133 -0
  146. data/lib/carat/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  147. data/lib/carat/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
  148. data/lib/carat/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
  149. data/lib/carat/vendor/thor/lib/thor/error.rb +32 -0
  150. data/lib/carat/vendor/thor/lib/thor/group.rb +281 -0
  151. data/lib/carat/vendor/thor/lib/thor/invocation.rb +178 -0
  152. data/lib/carat/vendor/thor/lib/thor/line_editor.rb +17 -0
  153. data/lib/carat/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
  154. data/lib/carat/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  155. data/lib/carat/vendor/thor/lib/thor/parser.rb +4 -0
  156. data/lib/carat/vendor/thor/lib/thor/parser/argument.rb +73 -0
  157. data/lib/carat/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  158. data/lib/carat/vendor/thor/lib/thor/parser/option.rb +125 -0
  159. data/lib/carat/vendor/thor/lib/thor/parser/options.rb +218 -0
  160. data/lib/carat/vendor/thor/lib/thor/rake_compat.rb +71 -0
  161. data/lib/carat/vendor/thor/lib/thor/runner.rb +322 -0
  162. data/lib/carat/vendor/thor/lib/thor/shell.rb +81 -0
  163. data/lib/carat/vendor/thor/lib/thor/shell/basic.rb +421 -0
  164. data/lib/carat/vendor/thor/lib/thor/shell/color.rb +149 -0
  165. data/lib/carat/vendor/thor/lib/thor/shell/html.rb +126 -0
  166. data/lib/carat/vendor/thor/lib/thor/util.rb +267 -0
  167. data/lib/carat/vendor/thor/lib/thor/version.rb +3 -0
  168. data/lib/carat/vendored_fileutils.rb +9 -0
  169. data/lib/carat/vendored_molinillo.rb +2 -0
  170. data/lib/carat/vendored_persistent.rb +11 -0
  171. data/lib/carat/vendored_thor.rb +3 -0
  172. data/lib/carat/version.rb +6 -0
  173. data/lib/carat/vlad.rb +11 -0
  174. data/lib/carat/worker.rb +73 -0
  175. data/man/carat-config.ronn +178 -0
  176. data/man/carat-exec.ronn +136 -0
  177. data/man/carat-install.ronn +383 -0
  178. data/man/carat-package.ronn +66 -0
  179. data/man/carat-platform.ronn +42 -0
  180. data/man/carat-update.ronn +188 -0
  181. data/man/carat.ronn +98 -0
  182. data/man/gemfile.5.ronn +473 -0
  183. data/man/index.txt +7 -0
  184. metadata +321 -0
@@ -0,0 +1,32 @@
1
+ module Carat
2
+ class AnonymizableURI
3
+ attr_reader :original_uri,
4
+ :without_credentials
5
+
6
+ def initialize(original_uri, fallback_auth = nil)
7
+ @original_uri = apply_auth(original_uri, fallback_auth).freeze
8
+ @without_credentials = remove_auth(@original_uri).freeze
9
+ end
10
+
11
+ private
12
+
13
+ def apply_auth(uri, auth = nil)
14
+ if auth && uri.userinfo.nil?
15
+ uri = uri.dup
16
+ uri.userinfo = auth
17
+ end
18
+
19
+ uri
20
+ end
21
+
22
+ def remove_auth(uri)
23
+ if uri.userinfo
24
+ uri = uri.dup
25
+ uri.user = uri.password = nil
26
+ end
27
+
28
+ uri
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ # Capistrano task for Carat.
2
+ #
3
+ # Just add "require 'carat/capistrano'" in your Capistrano deploy.rb, and
4
+ # Carat will be activated after each new deployment.
5
+ require 'carat/deployment'
6
+ require 'capistrano/version'
7
+
8
+ if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
9
+ raise "For Capistrano 3.x integration, please use http://github.com/capistrano/bundler"
10
+ end
11
+
12
+ Capistrano::Configuration.instance(:must_exist).load do
13
+ before "deploy:finalize_update", "carat:install"
14
+ Carat::Deployment.define_task(self, :task, :except => { :no_release => true })
15
+ set :rake, lambda { "#{fetch(:bundle_cmd, "carat")} exec rake" }
16
+ end
@@ -0,0 +1,407 @@
1
+ require 'carat'
2
+ require 'carat/vendored_thor'
3
+
4
+ module Carat
5
+ class CLI < Thor
6
+ include Thor::Actions
7
+ AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean]
8
+
9
+ def self.start(*)
10
+ super
11
+ rescue Exception => e
12
+ Carat.ui = UI::Shell.new
13
+ raise e
14
+ end
15
+
16
+ def initialize(*args)
17
+ super
18
+ current_cmd = args.last[:current_command].name
19
+ custom_gemfile = options[:gemfile] || Carat.settings[:gemfile]
20
+ ENV['BUNDLE_GEMFILE'] = File.expand_path(custom_gemfile) if custom_gemfile
21
+ Carat::Retry.attempts = options[:retry] || Carat.settings[:retry] || Carat::Retry::DEFAULT_ATTEMPTS
22
+ Carat.rubygems.ui = UI::RGProxy.new(Carat.ui)
23
+ auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
24
+ rescue UnknownArgumentError => e
25
+ raise InvalidOption, e.message
26
+ ensure
27
+ self.options ||= {}
28
+ Carat.ui = UI::Shell.new(options)
29
+ Carat.ui.level = "debug" if options["verbose"]
30
+ end
31
+
32
+ check_unknown_options!(:except => [:config, :exec])
33
+ stop_on_unknown_option! :exec
34
+
35
+ default_task :install
36
+ class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
37
+ class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
38
+ :desc => "Specify the number of times you wish to attempt network commands"
39
+ class_option "verbose", :type => :boolean, :desc => "Enable verbose output mode", :aliases => "-V"
40
+
41
+ def help(cli = nil)
42
+ case cli
43
+ when "gemfile" then command = "gemfile.5"
44
+ when nil then command = "carat"
45
+ else command = "carat-#{cli}"
46
+ end
47
+
48
+ manpages = %w(
49
+ carat
50
+ carat-config
51
+ carat-exec
52
+ carat-install
53
+ carat-package
54
+ carat-update
55
+ carat-platform
56
+ gemfile.5)
57
+
58
+ if manpages.include?(command)
59
+ root = File.expand_path("../man", __FILE__)
60
+
61
+ if Carat.which("man") && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
62
+ Kernel.exec "man #{root}/#{command}"
63
+ else
64
+ puts File.read("#{root}/#{command}.txt")
65
+ end
66
+ else
67
+ super
68
+ end
69
+ end
70
+
71
+ def self.handle_no_command_error(command, has_namespace = $thor_runner)
72
+ return super unless command_path = Carat.which("carat-#{command}")
73
+
74
+ Kernel.exec(command_path, *ARGV[1..-1])
75
+ end
76
+
77
+ desc "init [OPTIONS]", "Generates a Gemfile into the current working directory"
78
+ long_desc <<-D
79
+ Init generates a default Gemfile in the current working directory. When adding a
80
+ Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
81
+ dependency listed in the gemspec file to the newly created Gemfile.
82
+ D
83
+ method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
84
+ def init
85
+ require 'carat/cli/init'
86
+ Init.new(options.dup).run
87
+ end
88
+
89
+ desc "check [OPTIONS]", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
90
+ long_desc <<-D
91
+ Check searches the local machine for each of the gems requested in the Gemfile. If
92
+ all gems are found, Carat prints a success message and exits with a status of 0.
93
+ If not, the first missing gem is listed and Carat exits status 1.
94
+ D
95
+ method_option "dry-run", :type => :boolean, :default => false, :banner =>
96
+ "Lock the Gemfile"
97
+ method_option "gemfile", :type => :string, :banner =>
98
+ "Use the specified gemfile instead of Gemfile"
99
+ method_option "path", :type => :string, :banner =>
100
+ "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Carat will remember this value for future installs on this machine"
101
+ def check
102
+ require 'carat/cli/check'
103
+ Check.new(options).run
104
+ end
105
+
106
+ desc "install [OPTIONS]", "Install the current environment to the system"
107
+ long_desc <<-D
108
+ Install will install all of the gems in the current bundle, making them available
109
+ for use. In a freshly checked out repository, this command will give you the same
110
+ gem versions as the last person who updated the Gemfile and ran `carat update`.
111
+
112
+ Passing [DIR] to install (e.g. vendor) will cause the unpacked gems to be installed
113
+ into the [DIR] directory rather than into system gems.
114
+
115
+ If the bundle has already been installed, carat will tell you so and then exit.
116
+ D
117
+ method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
118
+ "Generate bin stubs for bundled gems to ./bin"
119
+ method_option "clean", :type => :boolean, :banner =>
120
+ "Run carat clean automatically after install"
121
+ method_option "deployment", :type => :boolean, :banner =>
122
+ "Install using defaults tuned for deployment environments"
123
+ method_option "frozen", :type => :boolean, :banner =>
124
+ "Do not allow the Gemfile.lock to be updated after this install"
125
+ method_option "full-index", :type => :boolean, :banner =>
126
+ "Use the rubygems modern index instead of the API endpoint"
127
+ method_option "gemfile", :type => :string, :banner =>
128
+ "Use the specified gemfile instead of Gemfile"
129
+ method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
130
+ "Specify the number of jobs to run in parallel"
131
+ method_option "local", :type => :boolean, :banner =>
132
+ "Do not attempt to fetch gems remotely and use the gem cache instead"
133
+ method_option "no-cache", :type => :boolean, :banner =>
134
+ "Don't update the existing gem cache."
135
+ method_option "no-prune", :type => :boolean, :banner =>
136
+ "Don't remove stale gems from the cache."
137
+ method_option "path", :type => :string, :banner =>
138
+ "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Carat will remember this value for future installs on this machine"
139
+ method_option "quiet", :type => :boolean, :banner =>
140
+ "Only output warnings and errors."
141
+ method_option "shebang", :type => :string, :banner =>
142
+ "Specify a different shebang executable name than the default (usually 'ruby')"
143
+ method_option "standalone", :type => :array, :lazy_default => [], :banner =>
144
+ "Make a bundle that can work without the Carat runtime"
145
+ method_option "system", :type => :boolean, :banner =>
146
+ "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
147
+ method_option "trust-policy", :alias => "P", :type => :string, :banner =>
148
+ "Gem trust policy (like gem install -P). Must be one of " +
149
+ Carat.rubygems.security_policy_keys.join('|')
150
+ method_option "without", :type => :array, :banner =>
151
+ "Exclude gems that are part of the specified named group."
152
+
153
+ def install
154
+ require 'carat/cli/install'
155
+ Install.new(options.dup).run
156
+ end
157
+
158
+ desc "update [OPTIONS]", "update the current environment"
159
+ long_desc <<-D
160
+ Update will install the newest versions of the gems listed in the Gemfile. Use
161
+ update when you have changed the Gemfile, or if you want to get the newest
162
+ possible versions of the gems in the bundle.
163
+ D
164
+ method_option "full-index", :type => :boolean, :banner =>
165
+ "Use the rubygems modern index instead of the API endpoint"
166
+ method_option "group", :aliases => "-g", :type => :array, :banner =>
167
+ "Update a specific group"
168
+ method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
169
+ "Specify the number of jobs to run in parallel"
170
+ method_option "local", :type => :boolean, :banner =>
171
+ "Do not attempt to fetch gems remotely and use the gem cache instead"
172
+ method_option "quiet", :type => :boolean, :banner =>
173
+ "Only output warnings and errors."
174
+ method_option "source", :type => :array, :banner =>
175
+ "Update a specific source (and all gems associated with it)"
176
+ def update(*gems)
177
+ require 'carat/cli/update'
178
+ Update.new(options, gems).run
179
+ end
180
+
181
+ desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
182
+ long_desc <<-D
183
+ Show lists the names and versions of all gems that are required by your Gemfile.
184
+ Calling show with [GEM] will list the exact location of that gem on your machine.
185
+ D
186
+ method_option "paths", :type => :boolean,
187
+ :banner => "List the paths of all gems that are required by your Gemfile."
188
+ method_option "outdated", :type => :boolean,
189
+ :banner => "Show verbose output including whether gems are outdated."
190
+ def show(gem_name = nil)
191
+ require 'carat/cli/show'
192
+ Show.new(options, gem_name).run
193
+ end
194
+ map %w(list) => "show"
195
+
196
+ desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem"
197
+ long_desc <<-D
198
+ Generate binstubs for executables in [GEM]. Binstubs are put into bin,
199
+ or the --binstubs directory if one has been set.
200
+ D
201
+ method_option "force", :type => :boolean, :default => false, :banner =>
202
+ "Overwrite existing binstubs if they exist"
203
+ method_option "path", :type => :string, :lazy_default => "bin", :banner =>
204
+ "Binstub destination directory (default bin)"
205
+ def binstubs(*gems)
206
+ require 'carat/cli/binstubs'
207
+ Binstubs.new(options, gems).run
208
+ end
209
+
210
+ desc "outdated GEM [OPTIONS]", "list installed gems with newer versions available"
211
+ long_desc <<-D
212
+ Outdated lists the names and versions of gems that have a newer version available
213
+ in the given source. Calling outdated with [GEM [GEM]] will only check for newer
214
+ versions of the given gems. Prerelease gems are ignored by default. If your gems
215
+ are up to date, Carat will exit with a status of 0. Otherwise, it will exit 1.
216
+ D
217
+ method_option "local", :type => :boolean, :banner =>
218
+ "Do not attempt to fetch gems remotely and use the gem cache instead"
219
+ method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
220
+ method_option "source", :type => :array, :banner => "Check against a specific source"
221
+ method_option "strict", :type => :boolean, :banner =>
222
+ "Only list newer versions allowed by your Gemfile requirements"
223
+ def outdated(*gems)
224
+ require 'carat/cli/outdated'
225
+ Outdated.new(options, gems).run
226
+ end
227
+
228
+ desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true
229
+ method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
230
+ method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms, not just the current one"
231
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
232
+ def cache
233
+ require 'carat/cli/cache'
234
+ Cache.new(options).run
235
+ end
236
+
237
+ desc "package [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
238
+ method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
239
+ method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms, not just the current one"
240
+ method_option "cache-path", :type => :string, :banner =>
241
+ "Specify a different cache path than the default (vendor/cache)."
242
+ method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
243
+ method_option "no-install", :type => :boolean, :banner => "Don't actually install the gems, just package."
244
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
245
+ method_option "path", :type => :string, :banner =>
246
+ "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Carat will remember this value for future installs on this machine"
247
+ method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors."
248
+ long_desc <<-D
249
+ The package command will copy the .gem files for every gem in the bundle into the
250
+ directory ./vendor/cache. If you then check that directory into your source
251
+ control repository, others who check out your source will be able to install the
252
+ bundle without having to download any additional gems.
253
+ D
254
+ def package
255
+ require 'carat/cli/package'
256
+ Package.new(options).run
257
+ end
258
+ map %w(pack) => :package
259
+
260
+ desc "exec [OPTIONS]", "Run the command in context of the bundle"
261
+ method_option :keep_file_descriptors, :type => :boolean, :default => false
262
+ long_desc <<-D
263
+ Exec runs a command, providing it access to the gems in the bundle. While using
264
+ carat exec you can require and call the bundled gems as if they were installed
265
+ into the system wide Rubygems repository.
266
+ D
267
+ def exec(*args)
268
+ require 'carat/cli/exec'
269
+ Exec.new(options, args).run
270
+ end
271
+
272
+ desc "config NAME [VALUE]", "retrieve or set a configuration value"
273
+ long_desc <<-D
274
+ Retrieves or sets a configuration value. If only one parameter is provided, retrieve the value. If two parameters are provided, replace the
275
+ existing value with the newly provided one.
276
+
277
+ By default, setting a configuration value sets it for all projects
278
+ on the machine.
279
+
280
+ If a global setting is superceded by local configuration, this command
281
+ will show the current value, as well as any superceded values and
282
+ where they were specified.
283
+ D
284
+ def config(*args)
285
+ require 'carat/cli/config'
286
+ Config.new(options, args, self).run
287
+ end
288
+
289
+ desc "open GEM", "Opens the source directory of the given bundled gem"
290
+ def open(name)
291
+ require 'carat/cli/open'
292
+ Open.new(options, name).run
293
+ end
294
+
295
+ desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
296
+ def console(group = nil)
297
+ require 'carat/cli/console'
298
+ Console.new(options, group).run
299
+ end
300
+
301
+ desc "version", "Prints the carat's version information"
302
+ def version
303
+ Carat.ui.info "Carat version #{Carat::VERSION}"
304
+ end
305
+ map %w(-v --version) => :version
306
+
307
+ desc "licenses", "Prints the license of all gems in the bundle"
308
+ def licenses
309
+ Carat.load.specs.sort_by { |s| s.license.to_s }.reverse.each do |s|
310
+ gem_name = s.name
311
+ license = s.license || s.licenses
312
+
313
+ if license.empty?
314
+ Carat.ui.warn "#{gem_name}: Unknown"
315
+ else
316
+ Carat.ui.info "#{gem_name}: #{license}"
317
+ end
318
+ end
319
+ end
320
+
321
+ desc 'viz [OPTIONS]', "Generates a visual dependency graph"
322
+ long_desc <<-D
323
+ Viz generates a PNG file of the current Gemfile as a dependency graph.
324
+ Viz requires the ruby-graphviz gem (and its dependencies).
325
+ The associated gems must also be installed via 'carat install'.
326
+ D
327
+ method_option :file, :type => :string, :default => 'gem_graph', :aliases => '-f', :banner => "The name to use for the generated file. see format option"
328
+ method_option :format, :type => :string, :default => "png", :aliases => '-F', :banner => "This is output format option. Supported format is png, jpg, svg, dot ..."
329
+ method_option :requirements, :type => :boolean, :default => false, :aliases => '-r', :banner => "Set to show the version of each required dependency."
330
+ method_option :version, :type => :boolean, :default => false, :aliases => '-v', :banner => "Set to show each gem version."
331
+ method_option :without, :type => :array, :default => [], :banner => "Exclude gems that are part of the specified named group."
332
+ def viz
333
+ require 'carat/cli/viz'
334
+ Viz.new(options).run
335
+ end
336
+
337
+ desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a rubygem"
338
+ method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :desc => "Generate a binary for your library. Set a default with `carat config gem.mit true`."
339
+ method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `carat config gem.coc true`."
340
+ method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
341
+ :lazy_default => [ENV['CARAT_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? },
342
+ :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $CARAT_EDITOR)"
343
+ method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code"
344
+ method_option :mit, :type => :boolean, :desc => "Generate an MIT license file"
345
+ method_option :test, :type => :string, :lazy_default => 'rspec', :aliases => '-t', :banner => "rspec",
346
+ :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `carat config gem.test rspec`."
347
+ def gem(name)
348
+ require 'carat/cli/gem'
349
+ Gem.new(options, name, self).run
350
+ end
351
+
352
+ def self.source_root
353
+ File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
354
+ end
355
+
356
+ desc "clean [OPTIONS]", "Cleans up unused gems in your carat directory"
357
+ method_option "dry-run", :type => :boolean, :default => false, :banner =>
358
+ "Only print out changes, do not actually clean gems"
359
+ method_option "force", :type => :boolean, :default => false, :banner =>
360
+ "Forces clean even if --path is not set"
361
+ def clean
362
+ require 'carat/cli/clean'
363
+ Clean.new(options.dup).run
364
+ end
365
+
366
+ desc "platform [OPTIONS]", "Displays platform compatibility information"
367
+ method_option "ruby", :type => :boolean, :default => false, :banner =>
368
+ "only display ruby related platform information"
369
+ def platform
370
+ require 'carat/cli/platform'
371
+ Platform.new(options).run
372
+ end
373
+
374
+ desc "inject GEM VERSION ...", "Add the named gem(s), with version requirements, to the resolved Gemfile"
375
+ def inject(name, version, *gems)
376
+ require 'carat/cli/inject'
377
+ Inject.new(options, name, version, gems).run
378
+ end
379
+
380
+ desc "env", "Print information about the environment Carat is running under"
381
+ def env
382
+ Env.new.write($stdout)
383
+ end
384
+
385
+ private
386
+
387
+ # Automatically invoke `carat install` and resume if
388
+ # Carat.settings[:auto_install] exists. This is set through config cmd
389
+ # `carat config auto_install 1`.
390
+ #
391
+ # Note that this method `nil`s out the global Definition object, so it
392
+ # should be called first, before you instantiate anything like an
393
+ # `Installer` that'll keep a reference to the old one instead.
394
+ def auto_install
395
+ return unless Carat.settings[:auto_install]
396
+
397
+ begin
398
+ Carat.definition.specs
399
+ rescue GemNotFound
400
+ Carat.ui.info "Automatically installing missing gems."
401
+ Carat.reset!
402
+ invoke :install, []
403
+ Carat.reset!
404
+ end
405
+ end
406
+ end
407
+ end