elm_install 1.2.0 → 1.3.0

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
  SHA1:
3
- metadata.gz: 68ac8a8d664399020fed3aab08c9f510dfc0b342
4
- data.tar.gz: f4fcd64db986475dd59293484060510fd7a039fd
3
+ metadata.gz: 2c6f2e9e7bc312adb591680f029bb8ffe931d9eb
4
+ data.tar.gz: ae3e9b0a3d08c052f6dd9010fb36d55066e673b7
5
5
  SHA512:
6
- metadata.gz: 84484f3b601baeb593ec56dc8fb751b015795a64855ede99038bd245f4cd379103c756a58d05264ce8f4d2cc6c76403fe57499e83346ba16590ba995cb4b9c18
7
- data.tar.gz: 34745ee40861cf12e2511e6998b003239a09ac591defbd5f7889f0ad8d3aab0b0855ba6e17f49fb47f13d0d2be7d08865ae3480419236ff830ec8e2373d2a245
6
+ metadata.gz: b1c8dc7e9c48edc0e89d300b24dda4f82c184d57b4c3eb6b3540c1a762a2649c1febab6acd0ce267157114a4e34d371b365f1bbfe02381d4b1792b7b9b015517
7
+ data.tar.gz: abd5efb9133618afb67407f22fea9b554a31f88f706b572e803af6af2a67306903249ad69b6c4d838953a9d7344522be409667eda41294b28fcf02713e1df8c1
@@ -8,3 +8,7 @@ Metrics/MethodLength:
8
8
  Enabled: False
9
9
  Metrics/AbcSize:
10
10
  Enabled: False
11
+ ClassLength:
12
+ Enabled: False
13
+ ClassVars:
14
+ Enabled: False
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elm_install (1.2.0)
4
+ elm_install (1.3.0)
5
5
  adts (~> 0.1.2)
6
6
  commander (~> 4.4, >= 4.4.2)
7
7
  contracts (~> 0.16.0)
@@ -120,7 +120,7 @@ GEM
120
120
  simplecov-html (0.10.0)
121
121
  slop (3.6.0)
122
122
  smart_colored (1.1.1)
123
- solve (3.1.0)
123
+ solve (3.1.1)
124
124
  molinillo (>= 0.5)
125
125
  semverse (>= 1.1, < 3.0)
126
126
  sparkr (0.4.1)
data/Readme.md CHANGED
@@ -162,6 +162,12 @@ OPTIONS:
162
162
  --verbose
163
163
  ```
164
164
 
165
+ ## Known Issues
166
+ * Using the NPM package or the released binaries in windows while specifing a
167
+ relative directory as a package will fail because of the 2.2 travelling
168
+ ruby dependency. Using the >Ruby 2.3 with the gem installed works properly.
169
+ More #36
170
+
165
171
  ## FAQ
166
172
 
167
173
  #### Do I need to use SSH keys?
@@ -33,7 +33,12 @@ module ElmInstall
33
33
  when Branch::Just
34
34
  @branch.ref
35
35
  when Branch::Nothing
36
- version.to_simple
36
+ case version
37
+ when String
38
+ version
39
+ else
40
+ version.to_simple
41
+ end
37
42
  end
38
43
 
39
44
  repository.checkout ref
@@ -63,14 +68,15 @@ module ElmInstall
63
68
  nil
64
69
  end
65
70
 
66
- Contract ArrayOf[Solve::Constraint] => ArrayOf[Semverse::Version]
71
+ Contract ArrayOf[Solve::Constraint], String => ArrayOf[Semverse::Version]
67
72
  # Returns the available versions for a repository
68
73
  #
69
74
  # @param constraints [Array] The constraints
75
+ # @param elm_version [String] The Elm version to match against
70
76
  #
71
77
  # @return [Array] The versions
72
- def versions(constraints)
73
- if repository.cloned?
78
+ def versions(constraints, elm_version)
79
+ if repository.cloned? && !repository.fetched?
74
80
  # Get updates from upstream
75
81
  Logger.arrow "Getting updates for: #{package_name.bold}"
76
82
  repository.fetch
@@ -80,21 +86,23 @@ module ElmInstall
80
86
  when Branch::Just
81
87
  [identifier.version(fetch(@branch.ref))]
82
88
  when Branch::Nothing
83
- matching_versions constraints
89
+ matching_versions constraints, elm_version
84
90
  end
85
91
  end
86
92
 
87
- Contract ArrayOf[Solve::Constraint] => ArrayOf[Semverse::Version]
93
+ Contract ArrayOf[Solve::Constraint], String => ArrayOf[Semverse::Version]
88
94
  # Returns the matchign versions for a repository for the given constraints
89
95
  #
90
96
  # @param constraints [Array] The constraints
97
+ # @param elm_version [String] The Elm version to match against
91
98
  #
92
99
  # @return [Array] The versions
93
- def matching_versions(constraints)
100
+ def matching_versions(constraints, elm_version)
94
101
  repository
95
102
  .versions
96
103
  .select do |version|
97
- constraints.all? { |constraint| constraint.satisfies?(version) }
104
+ identifier.elm_version(fetch(version.to_s)) == elm_version &&
105
+ constraints.all? { |constraint| constraint.satisfies?(version) }
98
106
  end
99
107
  .sort
100
108
  .reverse
@@ -7,6 +7,9 @@ module ElmInstall
7
7
  # @return [Hash] The options
8
8
  attr_reader :options
9
9
 
10
+ # @return [String] The initial Elm version
11
+ attr_reader :initial_elm_version
12
+
10
13
  Contract Dir, Hash => Identifier
11
14
  # Initialize a new identifier.
12
15
  #
@@ -17,6 +20,7 @@ module ElmInstall
17
20
  def initialize(directory, options = {})
18
21
  @options = options
19
22
  @dependency_sources = dependency_sources directory
23
+ @initial_elm_version = elm_version directory
20
24
  @initial_dependencies = identify directory
21
25
  self
22
26
  end
@@ -41,6 +45,24 @@ module ElmInstall
41
45
  Semverse::Version.new(json(directory)['version'])
42
46
  end
43
47
 
48
+ Contract Dir => String
49
+ # Returns the Elm version for a package
50
+ #
51
+ # @param directory [Dir] The directory
52
+ #
53
+ # @return [String] The version
54
+ def elm_version(directory)
55
+ if json(directory)['elm-version'] =~ /<\s*0\.19/
56
+ '0.18'
57
+ elsif json(directory)['elm-version'] =~ /<\s*0\.18/
58
+ '0.17'
59
+ elsif json(directory)['elm-version'] =~ /<\s*0\.17/
60
+ '0.16'
61
+ else
62
+ ''
63
+ end
64
+ end
65
+
44
66
  Contract Dir => ArrayOf[Dependency]
45
67
  # Identifies dependencies from a directory
46
68
  #
@@ -11,7 +11,7 @@ module ElmInstall
11
11
  # @return [String]
12
12
  attr_reader :path
13
13
 
14
- def_delegators :repo, :fetch
14
+ @@fetched = {}
15
15
 
16
16
  Contract String, String => Repository
17
17
  # Initializes a repository.
@@ -76,6 +76,22 @@ module ElmInstall
76
76
  Dir.exist?(path)
77
77
  end
78
78
 
79
+ # Returns if the repository has been fetched yet or not.
80
+ #
81
+ # @return [Bool]
82
+ def fetched?
83
+ @@fetched.key?(url)
84
+ end
85
+
86
+ # Fetches changes from a repository
87
+ #
88
+ # @return [Void]
89
+ def fetch
90
+ return if fetched?
91
+ repo.fetch
92
+ @@fetched[url] = true
93
+ end
94
+
79
95
  Contract None => Git::Base
80
96
  # Clones the repository
81
97
  #
@@ -83,6 +99,7 @@ module ElmInstall
83
99
  def clone
84
100
  Logger.arrow "Package: #{url.bold} not found in cache, cloning..."
85
101
  FileUtils.mkdir_p path
102
+ @@fetched[url] = true
86
103
  @repo = Git.clone(url, path)
87
104
  end
88
105
  end
@@ -36,14 +36,13 @@ module ElmInstall
36
36
  #
37
37
  # @return nil
38
38
  def resolve_dependency(dependency)
39
- return if @dependencies[dependency.name]
40
-
41
39
  @dependencies[dependency.name] ||= dependency
42
40
 
43
41
  dependency
44
42
  .source
45
- .versions(dependency.constraints)
43
+ .versions(dependency.constraints, @identifier.initial_elm_version)
46
44
  .each do |version|
45
+ next if @graph.artifact?(dependency.name, version)
47
46
  resolve_dependencies(dependency, version)
48
47
  end
49
48
 
@@ -1,4 +1,4 @@
1
1
  module ElmInstall
2
2
  # The version of ElmInstall
3
- VERSION = '1.2.0'.freeze
3
+ VERSION = '1.3.0'.freeze
4
4
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elm-github-install",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Install Elm packages directly from Git repositories",
5
5
  "scripts": {
6
6
  "install": "node scripts/install.js",
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  ruby '2.2.2'
4
4
 
5
- gem 'elm_install', '1.2.0'
5
+ gem 'elm_install', '1.3.0'
@@ -5,26 +5,25 @@ GEM
5
5
  commander (4.4.3)
6
6
  highline (~> 1.7.2)
7
7
  contracts (0.16.0)
8
- elm_install (1.1.0)
8
+ elm_install (1.2.0)
9
9
  adts (~> 0.1.2)
10
10
  commander (~> 4.4, >= 4.4.2)
11
11
  contracts (~> 0.16.0)
12
12
  git (~> 1.3)
13
13
  git_clone_url (~> 2.0)
14
- hashdiff (~> 0.3.1)
15
14
  indentation (~> 0.1.1)
15
+ molinillo (= 0.5.7)
16
16
  smart_colored (~> 1.1, >= 1.1.1)
17
17
  solve (~> 3.1)
18
18
  git (1.3.0)
19
19
  git_clone_url (2.0.0)
20
20
  uri-ssh_git (>= 2.0)
21
- hashdiff (0.3.4)
22
21
  highline (1.7.8)
23
22
  indentation (0.1.1)
24
23
  molinillo (0.5.7)
25
24
  semverse (2.0.0)
26
25
  smart_colored (1.1.1)
27
- solve (3.1.0)
26
+ solve (3.1.1)
28
27
  molinillo (>= 0.5)
29
28
  semverse (>= 1.1, < 3.0)
30
29
  uri-ssh_git (2.0.0)
@@ -33,7 +32,7 @@ PLATFORMS
33
32
  ruby
34
33
 
35
34
  DEPENDENCIES
36
- elm_install (= 1.1.0)
35
+ elm_install (= 1.2.0)
37
36
 
38
37
  RUBY VERSION
39
38
  ruby 2.2.2p95
@@ -1,8 +1,7 @@
1
1
  describe ElmInstall do
2
2
  it 'should install packages' do
3
- expect(ElmInstall::Logger)
3
+ allow(ElmInstall::Logger)
4
4
  .to receive(:arrow)
5
- .twice
6
5
 
7
6
  expect_any_instance_of(ElmInstall::Installer)
8
7
  .to receive(:install)
@@ -50,11 +50,24 @@ describe ElmInstall::GitSource do
50
50
  expect(repository)
51
51
  .to receive(:fetch)
52
52
 
53
+ expect(repository)
54
+ .to receive(:fetched?)
55
+ .and_return(false)
56
+
53
57
  expect(repository)
54
58
  .to receive(:versions)
55
59
  .and_return([Semverse::Version.new('1.0.0')])
56
60
 
57
- subject.versions([])
61
+ expect(repository)
62
+ .to receive(:checkout)
63
+ .with('1.0.0')
64
+ .and_return(Dir.new('.'))
65
+
66
+ expect(subject)
67
+ .to receive(:identifier)
68
+ .and_return(double(elm_version: '0.18'))
69
+
70
+ subject.versions([], '0.18')
58
71
  end
59
72
  end
60
73
 
@@ -88,6 +101,10 @@ describe ElmInstall::GitSource do
88
101
  expect(repository)
89
102
  .to receive(:fetch)
90
103
 
104
+ expect(repository)
105
+ .to receive(:fetched?)
106
+ .and_return(false)
107
+
91
108
  expect(subject)
92
109
  .to receive(:identifier)
93
110
  .and_return(double(version: Semverse::Version.new('1.0.0')))
@@ -96,7 +113,7 @@ describe ElmInstall::GitSource do
96
113
  .to receive(:checkout)
97
114
  .and_return(Dir.new('.'))
98
115
 
99
- subject.versions([])
116
+ subject.versions([], '0.18')
100
117
  end
101
118
  end
102
119
  end
@@ -107,11 +124,24 @@ describe ElmInstall::GitSource do
107
124
  expect(repository)
108
125
  .to receive(:fetch)
109
126
 
127
+ expect(repository)
128
+ .to receive(:fetched?)
129
+ .and_return(false)
130
+
131
+ expect(repository)
132
+ .to receive(:checkout)
133
+ .with('1.0.0')
134
+ .and_return(Dir.new('.'))
135
+
136
+ expect(subject)
137
+ .to receive(:identifier)
138
+ .and_return(double(elm_version: '0.18'))
139
+
110
140
  expect(repository)
111
141
  .to receive(:versions)
112
142
  .and_return([Semverse::Version.new('1.0.0')])
113
143
 
114
- subject.versions([])
144
+ subject.versions([], '0.18')
115
145
  end
116
146
  end
117
147
  end
@@ -32,9 +32,8 @@ describe ElmInstall::Identifier do
32
32
  let(:package_json) { '' }
33
33
 
34
34
  it 'throws an error' do
35
- expect(ElmInstall::Logger)
35
+ allow(ElmInstall::Logger)
36
36
  .to receive(:arrow)
37
- .twice
38
37
 
39
38
  subject
40
39
  end
@@ -29,11 +29,10 @@ describe ElmInstall::Installer do
29
29
 
30
30
  context 'sucessfull install' do
31
31
  before do
32
- expect(File)
32
+ allow(File)
33
33
  .to receive(:read)
34
34
  .with(File.join(Dir.pwd, 'elm-package.json'))
35
35
  .and_return(main_package)
36
- .twice
37
36
 
38
37
  expect(File)
39
38
  .to receive(:read)
@@ -74,11 +73,10 @@ describe ElmInstall::Installer do
74
73
  end
75
74
 
76
75
  before do
77
- expect(File)
76
+ allow(File)
78
77
  .to receive(:read)
79
78
  .with(File.join(Dir.pwd, 'elm-package.json'))
80
79
  .and_return(main_package)
81
- .twice
82
80
 
83
81
  expect(subject)
84
82
  .to receive(:results)
@@ -6,6 +6,7 @@ RSpec.configure do |config|
6
6
  config.before do
7
7
  allow(Process).to receive(:exit)
8
8
  allow(ElmInstall::Logger).to receive(:puts)
9
+ ElmInstall::Repository.class_variable_set('@@fetched', {})
9
10
  FileUtils.mkdir_p CACHE_DIRECTORY
10
11
  end
11
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elm_install
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusztáv Szikszai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-04 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git