devpack 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88ec4f3a9263a0ce2204ff40a97c9f502897ad2eab40d5ec9356dcab0dccdd10
4
- data.tar.gz: 5e6e9173e18339fa091cda8780588b0378c95c9589f8344a328d2e368f6649fa
3
+ metadata.gz: bc62279883bef6f044e47c419b853c89b33e76f699d7106575cd87869967b36d
4
+ data.tar.gz: 48a959cbd1004dce6752b6fb723905ad40f92c02cf73cd8432b969309d94f5a8
5
5
  SHA512:
6
- metadata.gz: 99bce1bb4528c5a2da45d6165481a05334688dec0c9a5f8bd6ac8778e4a85ca3dca45331134881a2d57b4bf0a664e1341541158456b48dde40e264dce7badcea
7
- data.tar.gz: 693c4a80282a14cc25a4be573d8b3de84823083251e3a8417b6c056edcba1d5e3170700962d86ef5dccb1508b8185fd9f124fc138d46af9c4ac3e175a164edef
6
+ metadata.gz: a473937535208f922c6ceed0e137cfa758bf806bb39516e6f01906d748ef219c0fcb69fba33e195c49e95f045cf335267b7b997f300c30e6311792becba6a4ea
7
+ data.tar.gz: 5e4247975b02ec3432344755432bb887ca7036cdb9792a3c8377d3a091dc5c92a464e0e8cf5dcda82248f2039e4c6ca0efedacf4761bec870d0d2fe6101cd254
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.8
1
+ 2.5.9
data/README.md CHANGED
@@ -49,10 +49,20 @@ When using a per-project configuration, `.devpack` files should be added to `.gi
49
49
 
50
50
  A convenience command is provided to install all gems listed in `.devpack` file that are not already installed:
51
51
 
52
- ```ruby
52
+ ```bash
53
53
  bundle exec devpack install
54
54
  ```
55
55
 
56
+ ### Executing Commands Provided by DevPack Gems
57
+
58
+ Use the `exec` command to run a command provided by a gem installed via _Devpack_.
59
+
60
+ An example use case of this is the [Guard](https://github.com/guard/guard) gem:
61
+
62
+ ```bash
63
+ bundle exec devpack exec guard
64
+ ```
65
+
56
66
  ### Initializers
57
67
 
58
68
  Custom initializers can be loaded by creating a directory named `.devpack_initializers` containing a set of `.rb` files.
data/exe/devpack CHANGED
@@ -1,32 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- ENV['DEVPACK_DISABLE'] = '1'
4
+ command = ARGV[0]
5
+
6
+ ENV['DEVPACK_DISABLE'] = '1' if command == 'install'
5
7
 
6
8
  require 'open3'
7
9
 
8
10
  require 'devpack'
9
11
 
10
- command = ARGV[0]
11
-
12
- if command == 'install'
13
- missing = Devpack::Gems.new(Devpack.config).tap { |gems| gems.load(silent: true) }.missing
14
- install_command = "bundle exec gem install -V #{missing.map(&:required_version).join(' ')}" unless missing.empty?
15
- if install_command.nil?
16
- warn '[devpack] No gems to install.'
17
- else
18
- warn "[devpack] [exec] #{install_command}"
19
- output, status = Open3.capture2e(install_command)
20
- puts output
21
- puts status
22
- if status.success?
23
- warn '[devpack] Installation complete.'
24
- else
25
- warn "[devpack] Installation failed. Manually verify this command: #{install_command}"
26
- end
27
- end
28
- exit 0
12
+ case command
13
+ when 'install'
14
+ require 'devpack/install'
15
+ when 'exec'
16
+ require 'devpack/exec'
17
+ else
18
+ warn "[devpack] Unknown command: #{command}"
19
+ exit 1
29
20
  end
30
-
31
- warn "[devpack] Unknown command: #{command}"
32
- exit 1
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem.module_eval do
4
+ def self.devpack_bin_path(gem_name, command, _version = nil)
5
+ File.join(Gem.loaded_specs[gem_name].full_gem_path, Gem.loaded_specs[gem_name].bindir, command)
6
+ end
7
+
8
+ class << self
9
+ alias_method :_orig_activate_bin_path, :activate_bin_path
10
+ alias_method :_orig_bin_path, :bin_path
11
+
12
+ def activate_bin_path(*args)
13
+ _orig_activate_bin_path(*args)
14
+ rescue Gem::Exception
15
+ devpack_bin_path(*args)
16
+ end
17
+
18
+ def bin_path(*args)
19
+ _orig_bin_path(*args)
20
+ rescue Gem::Exception
21
+ devpack_bin_path(*args)
22
+ end
23
+ end
24
+ end
25
+
26
+ def devpack_exec(args)
27
+ options = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new({ 'keep_file_descriptors' => true })
28
+ Bundler::CLI::Exec.new(options, args).run
29
+ end
30
+
31
+ devpack_exec(ARGV[1..-1])
@@ -44,8 +44,8 @@ module Devpack
44
44
  end
45
45
 
46
46
  def gem_path
47
- return ENV['GEM_PATH'] if ENV.key?('GEM_PATH')
48
- return ENV['GEM_HOME'] if ENV.key?('GEM_HOME')
47
+ return ENV.fetch('GEM_PATH', nil) if ENV.key?('GEM_PATH')
48
+ return ENV.fetch('GEM_HOME', nil) if ENV.key?('GEM_HOME')
49
49
 
50
50
  nil
51
51
  end
data/lib/devpack/gems.rb CHANGED
@@ -79,6 +79,7 @@ module Devpack
79
79
 
80
80
  def update_load_path(paths)
81
81
  $LOAD_PATH.concat(paths)
82
+ ENV['RUBYLIB'] = $LOAD_PATH.join(':')
82
83
  end
83
84
  end
84
85
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ missing = Devpack::Gems.new(Devpack.config).tap { |gems| gems.load(silent: true) }.missing
4
+ install_command = "bundle exec gem install -V #{missing.map(&:required_version).join(' ')}" unless missing.empty?
5
+ if install_command.nil?
6
+ Devpack.warn(:info, Devpack::Messages.no_gems_to_install)
7
+ else
8
+ Devpack.warn(:info, install_command)
9
+ output, status = Open3.capture2e(install_command)
10
+ if status.success?
11
+ Devpack.warn(:success, 'Installation complete.')
12
+ else
13
+ Devpack.warn(:error, "Installation failed. Manually verify this command: #{install_command}")
14
+ puts output
15
+ end
16
+ end
17
+ exit 0
@@ -52,6 +52,11 @@ module Devpack
52
52
  alert_incompatible_message(grouped_dependencies)
53
53
  end
54
54
 
55
+ def no_gems_to_install
56
+ "No gems to install: #{Devpack::Messages.color(:green) { Devpack.config.requested_gems.size.to_s }} "\
57
+ "gems already installed from #{Devpack::Messages.color(:cyan) { Devpack.config.devpack_path }}"
58
+ end
59
+
55
60
  def test
56
61
  puts "#{color(:green) { 'green' }} #{color(:red) { 'red' }} #{color(:blue) { 'blue' }}"
57
62
  puts "#{color(:cyan) { 'cyan' }} #{color(:yellow) { 'yellow' }} #{color(:magenta) { 'magenta' }}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Devpack
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-29 00:00:00.000000000 Z
11
+ date: 2023-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -119,10 +119,12 @@ files:
119
119
  - exe/devpack
120
120
  - lib/devpack.rb
121
121
  - lib/devpack/config.rb
122
+ - lib/devpack/exec.rb
122
123
  - lib/devpack/gem_glob.rb
123
124
  - lib/devpack/gem_spec.rb
124
125
  - lib/devpack/gems.rb
125
126
  - lib/devpack/initializers.rb
127
+ - lib/devpack/install.rb
126
128
  - lib/devpack/messages.rb
127
129
  - lib/devpack/railtie.rb
128
130
  - lib/devpack/timeable.rb
@@ -150,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
152
  - !ruby/object:Gem::Version
151
153
  version: '0'
152
154
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.7.6.2
155
+ rubygems_version: 3.2.3
155
156
  signing_key:
156
157
  specification_version: 4
157
158
  summary: Conveniently tailor your development environment