elm_install 1.5.0 → 1.6.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: 2eef6ee3e76e1ac9e302cc1a1a2776925f3bd553
4
- data.tar.gz: 3e139982a61ea46d381a7dcc3183ff14fd207062
3
+ metadata.gz: 8bf6faaacd71f18c899968687b3075919b8a100f
4
+ data.tar.gz: 03225cc158d380f2fcfc0f6d46d77cab10eec11f
5
5
  SHA512:
6
- metadata.gz: ad1ad2907b5d3d41e8d09466460cdd2d808664ded82bfffde02f9e477afc21e4432ac6e2af7ea59c71b3ce4eb78a5a909cd185c08bb3f62b89f886e35244ec03
7
- data.tar.gz: 821de6566529eb7223913d51c88609b26dfece98a0bdceccbdebc60b3624afe8aaaf34033f48a5c7be38740da4b0e6549dee3658ba60964c6f20d97246d0efe1
6
+ metadata.gz: 0be587f84093f0166054966faee8865063e239973c33d92a71c82b3cefb56058ad8855975e8825bde2abdea80d4172ed0f56c254779bbc0819c07418f85c7554
7
+ data.tar.gz: d960525811786839601e2ad9616cf64cb334b8e4fd1ecab6952200ba0917f0175ce978e9abade0ca1d9c5fb4fa1e0f1acea5b9b8b7364cf898525a488a3e0ca3
@@ -4,9 +4,7 @@ AllCops:
4
4
  - 'vendor/**/*'
5
5
  Style/FrozenStringLiteralComment:
6
6
  Enabled: False
7
- Metrics/MethodLength:
8
- Enabled: False
9
- Metrics/AbcSize:
7
+ Metrics:
10
8
  Enabled: False
11
9
  ClassLength:
12
10
  Enabled: False
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elm_install (1.5.0)
4
+ elm_install (1.6.0)
5
5
  adts (~> 0.1.2)
6
6
  commander (~> 4.4, >= 4.4.2)
7
7
  contracts (~> 0.16.0)
data/Readme.md CHANGED
@@ -159,6 +159,12 @@ OPTIONS:
159
159
  --cache-directory STRING
160
160
  Specifies where the cache is stored
161
161
 
162
+ --skip-update
163
+ Skips the update stage of packages
164
+
165
+ --only-update STRING
166
+ Only updates the given package
167
+
162
168
  --verbose
163
169
  ```
164
170
 
@@ -13,10 +13,14 @@ command :install do |c|
13
13
  c.summary = 'Install Elm packages from the elm-package.json file.'
14
14
  c.option '--cache-directory STRING', String,
15
15
  'Specifies where the cache is stored'
16
+ c.option '--skip-update', 'Skips the update stage of packages'
17
+ c.option '--only-update STRING', 'Only updates the given package'
16
18
  c.option '--verbose'
17
19
  c.action do |_args, options|
18
20
  ElmInstall.install(
19
21
  verbose: options.verbose,
22
+ skip_update: options.skip_update,
23
+ only_update: options.only_update,
20
24
  cache_directory: options.cache_directory ||
21
25
  File.join(Dir.home, '.elm-install')
22
26
  )
@@ -80,15 +80,21 @@ module ElmInstall
80
80
  @@elm_versions[url][ref] ||= identifier.elm_version(fetch(ref))
81
81
  end
82
82
 
83
- Contract ArrayOf[Solve::Constraint], String => ArrayOf[Semverse::Version]
83
+ Contract ArrayOf[Solve::Constraint],
84
+ String,
85
+ Bool,
86
+ Or[String, NilClass] => ArrayOf[Semverse::Version]
84
87
  # Returns the available versions for a repository
85
88
  #
86
89
  # @param constraints [Array] The constraints
87
90
  # @param elm_version [String] The Elm version to match against
88
91
  #
89
92
  # @return [Array] The versions
90
- def versions(constraints, elm_version)
91
- if repository.cloned? && !repository.fetched?
93
+ def versions(constraints, elm_version, should_update, only_update)
94
+ if repository.cloned? &&
95
+ !repository.fetched &&
96
+ should_update &&
97
+ (!only_update || only_update == package_name)
92
98
  # Get updates from upstream
93
99
  Logger.arrow "Getting updates for: #{package_name.bold}"
94
100
  repository.fetch
@@ -167,7 +173,7 @@ module ElmInstall
167
173
  #
168
174
  # @return [Repository] The repository
169
175
  def repository
170
- @repository ||= Repository.new url, path
176
+ @repository ||= Repository.of url, path
171
177
  end
172
178
 
173
179
  Contract None => Or[String, NilClass]
@@ -2,6 +2,8 @@ module ElmInstall
2
2
  # Installer class
3
3
  class Installer < Base
4
4
  Contract KeywordArgs[cache_directory: Or[String, NilClass],
5
+ skip_update: Or[Bool, NilClass],
6
+ only_update: Or[String, NilClass],
5
7
  verbose: Or[Bool, NilClass]] => Installer
6
8
  # Initializes an installer with the given options
7
9
  #
@@ -10,7 +12,7 @@ module ElmInstall
10
12
  # @return [Installer] The installer instance
11
13
  def initialize(options = {})
12
14
  @identifier = Identifier.new Dir.new(Dir.pwd), options
13
- @resolver = Resolver.new @identifier
15
+ @resolver = Resolver.new @identifier, options
14
16
  self
15
17
  end
16
18
 
@@ -11,7 +11,21 @@ module ElmInstall
11
11
  # @return [String]
12
12
  attr_reader :path
13
13
 
14
- @@fetched = {}
14
+ # Whether or not the repository has been fetched (updated)
15
+ # @return [Bool]
16
+ attr_reader :fetched
17
+
18
+ Contract String, String => Repository
19
+ # Returns the repository for the given url and path
20
+ #
21
+ # @param url [String] The url
22
+ # @param path [String] The path
23
+ #
24
+ # @return [Repository] The repository
25
+ def self.of(url, path)
26
+ @repositories ||= {}
27
+ @repositories[url] ||= new url, path
28
+ end
15
29
 
16
30
  Contract String, String => Repository
17
31
  # Initializes a repository.
@@ -21,6 +35,7 @@ module ElmInstall
21
35
  #
22
36
  # @return [Repository] The repository instance
23
37
  def initialize(url, path)
38
+ @fetched = false
24
39
  @path = path
25
40
  @url = url
26
41
  self
@@ -51,7 +66,8 @@ module ElmInstall
51
66
  #
52
67
  # @return [Array<Semverse::Version>] The versions
53
68
  def versions
54
- repo
69
+ @versions ||=
70
+ repo
55
71
  .tags
56
72
  .map(&:name)
57
73
  .select { |tag| tag =~ /(.*\..*\..*)/ }
@@ -77,20 +93,13 @@ module ElmInstall
77
93
  Dir.exist?(path)
78
94
  end
79
95
 
80
- # Returns if the repository has been fetched yet or not.
81
- #
82
- # @return [Bool]
83
- def fetched?
84
- @@fetched.key?(url)
85
- end
86
-
87
96
  # Fetches changes from a repository
88
97
  #
89
98
  # @return [Void]
90
99
  def fetch
91
- return if fetched?
100
+ return if fetched
92
101
  repo.fetch
93
- @@fetched[url] = true
102
+ @fetched = true
94
103
  end
95
104
 
96
105
  Contract None => Git::Base
@@ -100,7 +109,7 @@ module ElmInstall
100
109
  def clone
101
110
  Logger.arrow "Package: #{url.bold} not found in cache, cloning..."
102
111
  FileUtils.mkdir_p path
103
- @@fetched[url] = true
112
+ @fetched = true
104
113
  @repo = Git.clone(url, path)
105
114
  end
106
115
  end
@@ -4,16 +4,18 @@ module ElmInstall
4
4
  # @return [Array<Dependency>] The dependencies
5
5
  attr_reader :dependencies
6
6
 
7
- Contract Identifier => Resolver
7
+ Contract Identifier, Hash => Resolver
8
8
  # Initializes a resolver
9
9
  #
10
10
  # @param identifier [Identifier] The identifier
11
+ # @param options [Hash] The options
11
12
  #
12
13
  # @return [Resolver]
13
- def initialize(identifier)
14
+ def initialize(identifier, options = {})
14
15
  @graph = Solve::Graph.new
15
16
  @identifier = identifier
16
17
  @dependencies = {}
18
+ @options = options
17
19
  self
18
20
  end
19
21
 
@@ -40,7 +42,12 @@ module ElmInstall
40
42
 
41
43
  dependency
42
44
  .source
43
- .versions(dependency.constraints, @identifier.initial_elm_version)
45
+ .versions(
46
+ dependency.constraints,
47
+ @identifier.initial_elm_version,
48
+ !@options[:skip_update],
49
+ @options[:only_update]
50
+ )
44
51
  .each do |version|
45
52
  next if @graph.artifact?(dependency.name, version)
46
53
  resolve_dependencies(dependency, version)
@@ -1,4 +1,4 @@
1
1
  module ElmInstall
2
2
  # The version of ElmInstall
3
- VERSION = '1.5.0'.freeze
3
+ VERSION = '1.6.0'.freeze
4
4
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elm-github-install",
3
- "version": "1.5.0",
3
+ "version": "1.6.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.4.0'
5
+ gem 'elm_install', '1.5.0'
@@ -5,7 +5,7 @@ GEM
5
5
  commander (4.4.3)
6
6
  highline (~> 1.7.2)
7
7
  contracts (0.16.0)
8
- elm_install (1.4.0)
8
+ elm_install (1.5.0)
9
9
  adts (~> 0.1.2)
10
10
  commander (~> 4.4, >= 4.4.2)
11
11
  contracts (~> 0.16.0)
@@ -32,7 +32,7 @@ PLATFORMS
32
32
  ruby
33
33
 
34
34
  DEPENDENCIES
35
- elm_install (= 1.4.0)
35
+ elm_install (= 1.5.0)
36
36
 
37
37
  RUBY VERSION
38
38
  ruby 2.2.2p95
@@ -51,7 +51,7 @@ describe ElmInstall::GitSource do
51
51
  .to receive(:fetch)
52
52
 
53
53
  expect(repository)
54
- .to receive(:fetched?)
54
+ .to receive(:fetched)
55
55
  .and_return(false)
56
56
 
57
57
  expect(repository)
@@ -67,7 +67,7 @@ describe ElmInstall::GitSource do
67
67
  .to receive(:identifier)
68
68
  .and_return(double(elm_version: '0.18'))
69
69
 
70
- subject.versions([], '0.18')
70
+ subject.versions([], '0.18', true, nil)
71
71
  end
72
72
  end
73
73
 
@@ -102,7 +102,7 @@ describe ElmInstall::GitSource do
102
102
  .to receive(:fetch)
103
103
 
104
104
  expect(repository)
105
- .to receive(:fetched?)
105
+ .to receive(:fetched)
106
106
  .and_return(false)
107
107
 
108
108
  expect(subject)
@@ -113,7 +113,7 @@ describe ElmInstall::GitSource do
113
113
  .to receive(:checkout)
114
114
  .and_return(Dir.new('.'))
115
115
 
116
- subject.versions([], '0.18')
116
+ subject.versions([], '0.18', true, nil)
117
117
  end
118
118
  end
119
119
  end
@@ -125,7 +125,7 @@ describe ElmInstall::GitSource do
125
125
  .to receive(:fetch)
126
126
 
127
127
  expect(repository)
128
- .to receive(:fetched?)
128
+ .to receive(:fetched)
129
129
  .and_return(false)
130
130
 
131
131
  expect(repository)
@@ -141,7 +141,7 @@ describe ElmInstall::GitSource do
141
141
  .to receive(:versions)
142
142
  .and_return([Semverse::Version.new('1.0.0')])
143
143
 
144
- subject.versions([], '0.18')
144
+ subject.versions([], '0.18', true, nil)
145
145
  end
146
146
  end
147
147
  end
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.5.0
4
+ version: 1.6.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-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git