bundix 2.2.1 → 2.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4a1f9e593fc6268d9cbeed7ff01b5385e31ed5c
4
- data.tar.gz: c11ee93310970e0bbe33ec266c4c9f1d3a644d45
3
+ metadata.gz: 623983fdd769dae25b35ce73300b7c15e2e05406
4
+ data.tar.gz: 467820098d81bee233d3292e0a26cca9924e5c62
5
5
  SHA512:
6
- metadata.gz: b76ba25369c18f7fb22e8658ba796514aafabfa965ee1b14469b6d81fd28b8df3437f24dd57aee4b127fd36ba5df9cdb64c30d21756b87c23027a7fe2f37f427
7
- data.tar.gz: 1bd4b88b09ab7ebf5170c1da2585ab6ca01df9ffe43d93b2585bc5ab102d70ff8ba1fc073bed790eacce29f8381dafcf1ea8f587d74e21e090cbbd3a4ce09edc
6
+ metadata.gz: 730d8af2547d66f2fb33e1e5dd5c1afafec4f30dbc896de6f942552f485ae187e001f65ea786486553110f813e798e7cb8010f9c4012f9a82b686cc9b77bf359
7
+ data.tar.gz: e8e3ffa6148a782fe38c44128e11c86e836681eec0e03fddcccd2800b96a430f8f48f5e0c0923ef4b87787c6ccb14e3e5de18287a1acfe5a36c35f9bf9fa0e62
data/bin/bundix CHANGED
@@ -10,8 +10,9 @@ require_relative '../lib/bundix'
10
10
  options = {
11
11
  ruby: 'ruby',
12
12
  bundle_pack_path: 'vendor/bundle',
13
+ gemfile: 'Gemfile',
13
14
  lockfile: 'Gemfile.lock',
14
- gemset: 'gemset.nix'
15
+ gemset: 'gemset.nix',
15
16
  }
16
17
 
17
18
  op = OptionParser.new do |o|
@@ -39,18 +40,32 @@ op = OptionParser.new do |o|
39
40
  options[:lockfile] = File.expand_path(value)
40
41
  end
41
42
 
42
- o.on '-d', '--dependencies', 'include gem dependencies' do
43
- options[:deps] = true
43
+ o.on '--gemfile=Gemfile', 'path to the Gemfile' do |value|
44
+ options[:gemfile] = File.expand_path(value)
45
+ end
46
+
47
+ o.on '-d', '--dependencies', 'include gem dependencies (deprecated)' do
48
+ warn '--dependencies/-d is deprecated because'
49
+ warn 'dependencies will always be fetched'
44
50
  end
45
51
 
46
52
  o.on '-q', '--quiet', 'only output errors' do
47
53
  options[:quiet] = true
48
54
  end
49
55
 
56
+ o.on '-l', '--lock', 'generate Gemfile.lock first' do
57
+ options[:lock] = true
58
+ end
59
+
50
60
  o.on '-v', '--version', 'show the version of bundix' do
51
61
  puts Bundix::VERSION
52
62
  exit
53
63
  end
64
+
65
+ o.on '--env', 'show the environment in bundix' do
66
+ system('env')
67
+ exit
68
+ end
54
69
  end
55
70
 
56
71
  op.parse!
@@ -80,6 +95,15 @@ if options[:init]
80
95
  end
81
96
  end
82
97
 
98
+ if options[:lock]
99
+ lock = !File.file?(options[:lockfile])
100
+ lock ||= File.mtime(options[:gemfile]) > File.mtime(options[:lockfile])
101
+ if lock
102
+ system('bundle', 'lock')
103
+ fail 'bundle lock failed' unless $?.success?
104
+ end
105
+ end
106
+
83
107
  gemset = Bundix.new(options).convert
84
108
 
85
109
  tempfile = Tempfile.new('gemset.nix', encoding: 'UTF-8')
data/lib/bundix/source.rb CHANGED
@@ -16,10 +16,37 @@ class Bundix
16
16
  Bundix.sh(*args, &block)
17
17
  end
18
18
 
19
+ def download(file, url)
20
+ warn "Downloading #{file} from #{url}"
21
+ uri = URI(url)
22
+ open_options = {}
23
+ if uri.user && uri.password
24
+ open_options[:http_basic_authentication] = [uri.user, uri.password]
25
+ uri.user = nil
26
+ uri.password = nil
27
+ end
28
+ open(uri, 'r', 0600, open_options) do |net|
29
+ File.open(file, 'wb+') { |local|
30
+ File.copy_stream(net, local)
31
+ }
32
+ end
33
+ end
34
+
19
35
  def nix_prefetch_url(url)
20
- sh(NIX_BUILD, '--argstr', 'url', url, FETCHURL_FORCE, &FETCHURL_FORCE_CHECK)
21
- .force_encoding('UTF-8')
22
- rescue
36
+ dir = File.expand_path('~/.cache/bundix')
37
+ FileUtils.mkdir_p dir
38
+ file = File.join(dir, url.gsub(/[^\w-]+/, '_'))
39
+
40
+ unless File.size?(file)
41
+ download(file, url)
42
+ end
43
+
44
+ return unless File.size?(file)
45
+
46
+ sh('nix-prefetch-url', '--type', 'sha256', "file://#{file}")
47
+ .force_encoding('UTF-8').strip
48
+ rescue => ex
49
+ puts ex
23
50
  nil
24
51
  end
25
52
 
@@ -55,7 +82,7 @@ class Bundix
55
82
  uri = "#{remote}/gems/#{spec.name}-#{spec.version}.gem"
56
83
  result = nix_prefetch_url(uri)
57
84
  return unless result
58
- result.force_encoding('UTF-8')[SHA256_32]
85
+ result[SHA256_32]
59
86
  rescue => e
60
87
  puts "ignoring error during fetching: #{e}"
61
88
  puts e.backtrace
@@ -66,8 +93,8 @@ class Bundix
66
93
  remotes = spec.source.remotes.map{|remote| remote.to_s.sub(/\/+$/, '') }
67
94
  hash = fetch_local_hash(spec)
68
95
  remote, hash = fetch_remotes_hash(spec, remotes) unless hash
69
- hash = sh(NIX_HASH, '--type', 'sha256', '--to-base32', hash)[SHA256_32]
70
96
  fail "couldn't fetch hash for #{spec.name}-#{spec.version}" unless hash
97
+ hash = sh(NIX_HASH, '--type', 'sha256', '--to-base32', hash)[SHA256_32]
71
98
  puts "#{hash} => #{spec.name}-#{spec.version}.gem" if $VERBOSE
72
99
 
73
100
  { type: 'gem',
@@ -1,3 +1,3 @@
1
1
  class Bundix
2
- VERSION = '2.2.1'
2
+ VERSION = '2.3.0'
3
3
  end
data/lib/bundix.rb CHANGED
@@ -26,11 +26,7 @@ class Bundix
26
26
  attr_reader :options
27
27
 
28
28
  def initialize(options)
29
- @options = {
30
- quiet: false,
31
- tempfile: nil,
32
- deps: false
33
- }.merge(options)
29
+ @options = { quiet: false, tempfile: nil }.merge(options)
34
30
  end
35
31
 
36
32
  def convert
@@ -42,9 +38,7 @@ class Bundix
42
38
  gem = find_cached_spec(spec, cache) || convert_spec(spec, cache)
43
39
  gems.merge!(gem)
44
40
 
45
- if options[:deps] && spec.dependencies.any?
46
- gems[spec.name]['dependencies'] = spec.dependencies.map(&:name) - ['bundler']
47
- end
41
+ gems[spec.name]['dependencies'] = spec.dependencies.map(&:name) - ['bundler']
48
42
  end
49
43
  end
50
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundix
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael 'manveru' Fellinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-19 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler