elm_install 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.reek +4 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +4 -0
  5. data/Gemfile.lock +30 -25
  6. data/Rakefile +2 -2
  7. data/Readme.md +85 -23
  8. data/bin/elm-install +5 -2
  9. data/elm_install.gemspec +2 -0
  10. data/lib/elm_install.rb +18 -1
  11. data/lib/elm_install/base.rb +3 -46
  12. data/lib/elm_install/dependency.rb +37 -0
  13. data/lib/elm_install/directory_source.rb +66 -0
  14. data/lib/elm_install/ext.rb +23 -0
  15. data/lib/elm_install/git_source.rb +173 -0
  16. data/lib/elm_install/identifier.rb +133 -0
  17. data/lib/elm_install/installer.rb +38 -96
  18. data/lib/elm_install/populator.rb +54 -75
  19. data/lib/elm_install/repository.rb +82 -0
  20. data/lib/elm_install/resolver.rb +48 -118
  21. data/lib/elm_install/source.rb +18 -0
  22. data/lib/elm_install/types.rb +43 -0
  23. data/lib/elm_install/utils.rb +14 -20
  24. data/lib/elm_install/version.rb +1 -1
  25. data/package.json +1 -1
  26. data/packaging/Gemfile +1 -1
  27. data/packaging/Gemfile.lock +8 -4
  28. data/scripts/install.js +4 -4
  29. data/scripts/run.js +4 -4
  30. data/spec/directory_source_spec.rb +37 -0
  31. data/spec/{eml_install_spec.rb → elm_install_spec.rb} +6 -3
  32. data/spec/git_source_spec.rb +115 -0
  33. data/spec/identifer_spec.rb +53 -0
  34. data/spec/installer_spec.rb +57 -26
  35. data/spec/repository_spec.rb +44 -0
  36. data/spec/resolver_spec.rb +0 -73
  37. data/spec/spec_helper.rb +3 -1
  38. data/spec/utils_spec.rb +10 -15
  39. metadata +43 -17
  40. data/docs/How it works.md +0 -54
  41. data/lib/elm_install/cache.rb +0 -52
  42. data/lib/elm_install/elm_package.rb +0 -119
  43. data/lib/elm_install/git_resolver.rb +0 -129
  44. data/lib/elm_install/graph_builder.rb +0 -73
  45. data/spec/elm_package_spec.rb +0 -73
  46. data/spec/fixtures/cache.json +0 -8
  47. data/spec/fixtures/elm-package.json +0 -12
  48. data/spec/fixtures/invalid-elm-package.json +0 -6
  49. data/spec/fixtures/mismatched-elm-package.json +0 -9
  50. data/spec/fixtures/ref-cache.json +0 -4
  51. data/spec/git_resolver_spec.rb +0 -103
  52. data/spec/graph_builder_spec.rb +0 -36
  53. data/spec/populator_spec.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0d18a4779273c1b3132102c5f4740f2ad0f755e
4
- data.tar.gz: 978a7b2c7c6e8cef8ffe4de27d903990f1389d1d
3
+ metadata.gz: 135de9d0626d6405f8a3d794d61c61df46a82691
4
+ data.tar.gz: 7b19ca3f3f7ccdb6f08bcfc25173ffe6eacb5e4c
5
5
  SHA512:
6
- metadata.gz: f7482bd87dc668e476194cb782fb03e202324cf4b9fa41fd543c9d22a6ef1768e08290d1e47ecb006ce0c2cd290b048b8641c0e951a5d392d064aeef8c6a0c73
7
- data.tar.gz: 8cfd8e742406174371b9c17c4c3a4a5b5c28ea4ad07907ca8c1a9521eaf848f2eaf2074e60b80115895bea87b6a483b9d44b7ce868102d0969e9bcf2ddc22a94
6
+ metadata.gz: e2cec562fdb050f6d5094b734fd6a1bd9af060770ff4e6d8acbc63ac5bf7d5ba925084a8b52d42c4ca8498e1b87bae30959e474977837f97d0487b3311bc7224
7
+ data.tar.gz: 72c6dcbb7b493af368540289eb996e6ccd36239072b0aed5f090578b33d874858714ce7f366fb01e221088430717b9e2e081ccc3a6edf09cd6fe83c902dcd181
data/.reek CHANGED
@@ -2,3 +2,7 @@ TooManyStatements:
2
2
  max_statements: 7
3
3
  InstanceVariableAssumption:
4
4
  enabled: false
5
+ Attribute:
6
+ enabled: false
7
+ FeatureEnvy:
8
+ enabled: false
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --require spec_helper
@@ -4,3 +4,7 @@ AllCops:
4
4
  - 'vendor/**/*'
5
5
  Style/FrozenStringLiteralComment:
6
6
  Enabled: False
7
+ Metrics/MethodLength:
8
+ Enabled: False
9
+ Metrics/AbcSize:
10
+ Enabled: False
@@ -1,8 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elm_install (0.3.1)
4
+ elm_install (1.0.0)
5
+ adts (~> 0.1.2)
5
6
  commander (~> 4.4, >= 4.4.2)
7
+ contracts (~> 0.16.0)
6
8
  git (~> 1.3)
7
9
  git_clone_url (~> 2.0)
8
10
  hashdiff (~> 0.3.1)
@@ -13,8 +15,9 @@ PATH
13
15
  GEM
14
16
  remote: https://rubygems.org/
15
17
  specs:
16
- addressable (2.5.0)
18
+ addressable (2.5.1)
17
19
  public_suffix (~> 2.0, >= 2.0.2)
20
+ adts (0.1.2)
18
21
  ast (2.3.0)
19
22
  axiom-types (0.1.1)
20
23
  descendants_tracker (~> 0.0.4)
@@ -22,32 +25,33 @@ GEM
22
25
  thread_safe (~> 0.3, >= 0.3.1)
23
26
  codeclimate-engine-rb (0.4.0)
24
27
  virtus (~> 1.0)
25
- codeclimate-test-reporter (1.0.3)
26
- simplecov
28
+ codeclimate-test-reporter (1.0.8)
29
+ simplecov (<= 0.13)
27
30
  coderay (1.1.1)
28
31
  coercible (1.0.0)
29
32
  descendants_tracker (~> 0.0.1)
30
- commander (4.4.2)
33
+ commander (4.4.3)
31
34
  highline (~> 1.7.2)
35
+ contracts (0.16.0)
32
36
  descendants_tracker (0.0.4)
33
37
  thread_safe (~> 0.3, >= 0.3.1)
34
- diff-lcs (1.2.5)
38
+ diff-lcs (1.3)
35
39
  docile (1.1.5)
36
40
  equalizer (0.0.11)
37
41
  erubis (2.7.0)
38
- flay (2.8.1)
42
+ flay (2.9.0)
39
43
  erubis (~> 2.7.0)
40
44
  path_expander (~> 1.0)
41
45
  ruby_parser (~> 3.0)
42
46
  sexp_processor (~> 4.0)
43
- flog (4.4.0)
47
+ flog (4.6.1)
44
48
  path_expander (~> 1.0)
45
49
  ruby_parser (~> 3.1, > 3.1.0)
46
- sexp_processor (~> 4.4)
50
+ sexp_processor (~> 4.8)
47
51
  git (1.3.0)
48
52
  git_clone_url (2.0.0)
49
53
  uri-ssh_git (>= 2.0)
50
- hashdiff (0.3.1)
54
+ hashdiff (0.3.4)
51
55
  highline (1.7.8)
52
56
  ice_nine (0.11.2)
53
57
  inch (0.7.1)
@@ -56,12 +60,12 @@ GEM
56
60
  term-ansicolor
57
61
  yard (~> 0.8.7.5)
58
62
  indentation (0.1.1)
59
- json (2.0.2)
63
+ json (2.1.0)
60
64
  launchy (2.4.3)
61
65
  addressable (~> 2.3)
62
66
  method_source (0.8.2)
63
- molinillo (0.5.4)
64
- parser (2.3.3.1)
67
+ molinillo (0.5.7)
68
+ parser (2.4.0.0)
65
69
  ast (~> 2.2)
66
70
  path_expander (1.0.1)
67
71
  powerpack (0.1.1)
@@ -69,12 +73,13 @@ GEM
69
73
  coderay (~> 1.1.0)
70
74
  method_source (~> 0.8.1)
71
75
  slop (~> 3.4)
72
- public_suffix (2.0.4)
73
- rainbow (2.1.0)
76
+ public_suffix (2.0.5)
77
+ rainbow (2.2.2)
78
+ rake
74
79
  rake (12.0.0)
75
- reek (4.5.3)
80
+ reek (4.6.2)
76
81
  codeclimate-engine-rb (~> 0.4.0)
77
- parser (~> 2.3.1, >= 2.3.1.2)
82
+ parser (>= 2.4.0.0, < 2.5)
78
83
  rainbow (~> 2.0)
79
84
  rspec (3.5.0)
80
85
  rspec-core (~> 3.5.0)
@@ -96,19 +101,19 @@ GEM
96
101
  ruby-progressbar (~> 1.7)
97
102
  unicode-display_width (~> 1.0, >= 1.0.1)
98
103
  ruby-progressbar (1.8.1)
99
- ruby_parser (3.8.3)
104
+ ruby_parser (3.9.0)
100
105
  sexp_processor (~> 4.1)
101
- rubycritic (3.1.3)
106
+ rubycritic (3.2.0)
102
107
  flay (~> 2.8)
103
108
  flog (~> 4.4)
104
109
  launchy (= 2.4.3)
105
- parser (= 2.3.3.1)
110
+ parser (= 2.4.0)
106
111
  rainbow (~> 2.1)
107
112
  reek (~> 4.4)
108
113
  ruby_parser (~> 3.8)
109
114
  virtus (~> 1.0)
110
115
  semverse (2.0.0)
111
- sexp_processor (4.7.0)
116
+ sexp_processor (4.9.0)
112
117
  simplecov (0.12.0)
113
118
  docile (~> 1.1.0)
114
119
  json (>= 1.8, < 3)
@@ -120,11 +125,11 @@ GEM
120
125
  molinillo (>= 0.5)
121
126
  semverse (>= 1.1, < 3.0)
122
127
  sparkr (0.4.1)
123
- term-ansicolor (1.4.0)
128
+ term-ansicolor (1.6.0)
124
129
  tins (~> 1.0)
125
- thread_safe (0.3.5)
126
- tins (1.13.0)
127
- unicode-display_width (1.1.2)
130
+ thread_safe (0.3.6)
131
+ tins (1.13.2)
132
+ unicode-display_width (1.2.1)
128
133
  uri-ssh_git (2.0.0)
129
134
  virtus (1.0.5)
130
135
  axiom-types (~> 0.1)
data/Rakefile CHANGED
@@ -3,8 +3,8 @@ require 'bundler/setup'
3
3
  Bundler::GemHelper.install_tasks
4
4
 
5
5
  task :ci do
6
- sh 'rspec'
7
6
  sh 'rubocop'
8
7
  sh 'rubycritic -m --no-browser -s 90 lib'
9
- sh 'inch suggest lib --pedantic'
8
+ sh 'inch suggest lib'
9
+ sh 'rspec'
10
10
  end
data/Readme.md CHANGED
@@ -7,10 +7,12 @@
7
7
  [![Inline docs](http://inch-ci.org/github/gdotdesign/elm-github-install.svg?branch=master)](http://inch-ci.org/github/gdotdesign/elm-github-install)
8
8
  [![Build Status](https://travis-ci.org/gdotdesign/elm-github-install.svg?branch=master)](https://travis-ci.org/gdotdesign/elm-github-install)
9
9
 
10
- This gem allows you to install Elm packages **directly from any Git repository
11
- (even private ones)**, bypassing the package repository (package.elm-lang.org)
12
- while also enabling restricted (effect manager and native) packages to be
13
- installed.
10
+ This gem/npm-package allows you to install Elm packages **in a decentralized way from Git repositories**, this allows:
11
+ * installing of **effect manager** and **native** packages
12
+ * installing **forks of packages** for testing or unreleased features
13
+ * using packages from **local directories**
14
+ * installing **private packages** using private git repositories
15
+ * installing packages **offline** (packages are cached)
14
16
 
15
17
  ## Installation
16
18
 
@@ -58,27 +60,39 @@ Resolving packages...
58
60
  ▶ Package: https://github.com/elm-lang/virtual-dom not found in cache, cloning...
59
61
  ▶ Package: https://github.com/elm-lang/dom not found in cache, cloning...
60
62
  Solving dependencies...
61
- Saving package cache...
62
- ● elm-lang/core - 5.0.0 (5.0.0)
63
- ● elm-lang/svg - 2.0.0 (2.0.0)
64
- ● elm-lang/dom - 1.1.1 (1.1.1)
65
- ● elm-lang/html - 2.0.0 (2.0.0)
66
- ● elm-lang/virtual-dom - 2.0.3 (2.0.3)
63
+ elm-lang/core - https://github.com/elm-lang/core (5.1.1)
64
+ ● elm-lang/svg - https://github.com/elm-lang/svg (2.0.0)
65
+ ● elm-lang/dom - https://github.com/elm-lang/dom (1.1.1)
66
+ ● elm-lang/html - https://github.com/elm-lang/html (2.0.0)
67
+ ● elm-lang/virtual-dom - https://github.com/elm-lang/virtual-dom (2.0.4)
67
68
  Packages configured successfully!
68
69
  ```
69
70
 
70
71
  ## Advanced Usage
71
- Sources (urls for git repositories) can be defined in the `dependency-sources`
72
- field in `elm-package.json` for any package defined in the `dependencies`
73
- field. There is only one restriction: the pacakges name must match the path of
74
- the url of the git repository, this is because it could cause conflicts with
75
- other packages and with native code.
72
+ Sources can be defined in the `dependency-sources` field in `elm-package.json`
73
+ for any package defined in the `dependencies` field.
74
+
75
+ The source can be defined as:
76
+ * an URL pointing to a Git repository:
77
+ ```
78
+ "elm-lang/core": "git@github.com:someuser/core"
79
+ ```
80
+ * a hash containing the URL and the reference (tag, commit hash, branch) to use:
81
+ ```
82
+ "gdotdesign/elm-install-test": {
83
+ "url": "gdotdesign@bitbucket.org:gdotdesign/elm-install-test",
84
+ "ref": "master"
85
+ }
86
+ ```
87
+ * an absolute or relative path to the package in your hard drive:
88
+ ```
89
+ "elm-lang/dom": "../elm-lang/dom"
90
+ ```
76
91
 
77
- The source can be defined by a string (url) or a hash containing the url and the
78
- reference (tag, commit hash, branch) to use. If a reference is defined then
79
- the version in the `dependencies` field is ignored and the **version will be
80
- used from the `elm-package.json` at that reference**.
92
+ If a reference or a path is defined then the version in the `dependencies` field is
93
+ ignored and the **version will be used from the `elm-package.json` at that source**.
81
94
 
95
+ Examples:
82
96
  ```
83
97
  ...
84
98
  "dependencies": {
@@ -88,7 +102,8 @@ used from the `elm-package.json` at that reference**.
88
102
  "elm-lang/dom": "1.1.1 <= v < 2.0.0"
89
103
  },
90
104
  "dependency-sources": {
91
- "elm-lang/core": "git@github.com:elm-lang/core",
105
+ "elm-lang/core": "git@github.com:someuser/core",
106
+ "elm-lang/dom": "../elm-lang/dom",
92
107
  "gdotdesign/elm-install-test": {
93
108
  "url": "gdotdesign@bitbucket.org:gdotdesign/elm-install-test",
94
109
  "ref": "master"
@@ -97,6 +112,56 @@ used from the `elm-package.json` at that reference**.
97
112
  ...
98
113
  ```
99
114
 
115
+ ### CLI
116
+ Help for the `elm-install` command:
117
+ ```
118
+ NAME:
119
+
120
+ elm-install
121
+
122
+ DESCRIPTION:
123
+
124
+ Install Elm packages from Git repositories.
125
+
126
+ COMMANDS:
127
+
128
+ help Display global or [command] help documentation
129
+ install Install Elm packages from the elm-package.json file.
130
+
131
+ GLOBAL OPTIONS:
132
+
133
+ -h, --help
134
+ Display help documentation
135
+
136
+ -v, --version
137
+ Display version information
138
+
139
+ -t, --trace
140
+ Display backtrace when an error occurs
141
+ ```
142
+
143
+ Help for the `elm-install install` command.
144
+ ```
145
+ NAME:
146
+
147
+ install
148
+
149
+ SYNOPSIS:
150
+
151
+ elm-install install
152
+
153
+ DESCRIPTION:
154
+
155
+ Install Elm packages from the elm-package.json file.
156
+
157
+ OPTIONS:
158
+
159
+ --cache-directory STRING
160
+ Specifies where the cache is stored
161
+
162
+ --verbose
163
+ ```
164
+
100
165
  ## FAQ
101
166
 
102
167
  #### Do I need to use SSH keys?
@@ -115,6 +180,3 @@ The following protocols can be used:
115
180
  #### Can I install from private repositories?
116
181
  Yes private repositories are supported provided you have authentication
117
182
  (for example SSH keys).
118
-
119
- ## How is it work exactly?
120
- You can read more about it [here](docs/How it works.md).
@@ -15,8 +15,11 @@ command :install do |c|
15
15
  'Specifies where the cache is stored'
16
16
  c.option '--verbose'
17
17
  c.action do |_args, options|
18
- ElmInstall.install verbose: options.verbose,
19
- cache_directory: options.cache_directory
18
+ ElmInstall.install(
19
+ verbose: options.verbose,
20
+ cache_directory: options.cache_directory ||
21
+ File.join(Dir.home, '.elm-install')
22
+ )
20
23
  end
21
24
  end
22
25
 
@@ -25,6 +25,8 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency 'smart_colored', '~> 1.1', '>= 1.1.1'
26
26
  s.add_dependency 'hashdiff', '~> 0.3.1'
27
27
  s.add_dependency 'indentation', '~> 0.1.1'
28
+ s.add_dependency 'contracts', '~> 0.16.0'
29
+ s.add_dependency 'adts', '~> 0.1.2'
28
30
 
29
31
  s.extra_rdoc_files = ['Readme.md']
30
32
  end
@@ -3,12 +3,29 @@ require 'git_clone_url'
3
3
  require 'forwardable'
4
4
  require 'indentation'
5
5
  require 'fileutils'
6
+ require 'contracts'
6
7
  require 'hashdiff'
7
- require 'solve'
8
8
  require 'json'
9
+ require 'adts'
9
10
  require 'git'
10
11
 
12
+ require 'solve/constraint'
13
+ require 'solve'
14
+
11
15
  require_relative './elm_install/version'
16
+ require_relative './elm_install/utils'
17
+ require_relative './elm_install/logger'
18
+ require_relative './elm_install/ext'
19
+ require_relative './elm_install/base'
20
+ require_relative './elm_install/types'
21
+ require_relative './elm_install/source'
22
+ require_relative './elm_install/directory_source'
23
+ require_relative './elm_install/repository'
24
+ require_relative './elm_install/git_source'
25
+ require_relative './elm_install/dependency'
26
+ require_relative './elm_install/identifier'
27
+ require_relative './elm_install/resolver'
28
+ require_relative './elm_install/populator'
12
29
  require_relative './elm_install/installer'
13
30
 
14
31
  # The main module for the gem.
@@ -1,50 +1,7 @@
1
1
  module ElmInstall
2
- # This class is the base for the Cache and GitResolver packages.
2
+ # Base class that contains contracts.
3
3
  class Base
4
- extend Forwardable
5
-
6
- # @return [Hash] The current cache
7
- attr_reader :cache
8
-
9
- def_delegators :@cache, :each, :key?
10
-
11
- # Initializes a new base for a cache.
12
- #
13
- # @param options [Hash] The options
14
- def initialize(options = {})
15
- @options = options
16
- @cache = {}
17
- load
18
- end
19
-
20
- # Saves the cache into the json file.
21
- #
22
- # @return [void]
23
- def save
24
- File.binwrite(file, JSON.pretty_generate(@cache))
25
- end
26
-
27
- # Loads a cache from the json file.
28
- #
29
- # @return [void]
30
- def load
31
- @cache = JSON.parse(File.read(file))
32
- rescue
33
- @cache = {}
34
- end
35
-
36
- # Returns the patch of the cache file.
37
- #
38
- # @return [String] The path
39
- def file
40
- File.join(directory, @file)
41
- end
42
-
43
- # Returns the path of the directory where the cache is stored.
44
- #
45
- # @return [String] The path
46
- def directory
47
- @options[:directory]
48
- end
4
+ include Contracts::Core
5
+ include Contracts::Builtin
49
6
  end
50
7
  end
@@ -0,0 +1,37 @@
1
+ module ElmInstall
2
+ # Represents a dependency
3
+ class Dependency < Base
4
+ extend Forwardable
5
+
6
+ # @return [Array] The constraints for the dependency
7
+ attr_reader :constraints
8
+
9
+ # @overload version
10
+ # @return [Semverse::Version] The version
11
+ # @overload version=(value)
12
+ # Sets the version
13
+ # @param [Semverse::Version] The version
14
+ attr_accessor :version
15
+
16
+ # @return [Source] The source to use for resolving (Git, Directory)
17
+ attr_reader :source
18
+
19
+ # @return [String] The name of the dependency
20
+ attr_reader :name
21
+
22
+ Contract String, Source, ArrayOf[Solve::Constraint] => Dependency
23
+ # Initializes a new dependency.
24
+ #
25
+ # @param constraints [Array<Solve::Constraint>] The contraints
26
+ # @param source [Source] The source
27
+ # @param name [String] The name
28
+ #
29
+ # @return [Dependency] The dependency instance
30
+ def initialize(name, source, constraints)
31
+ @constraints = constraints
32
+ @source = source
33
+ @name = name
34
+ self
35
+ end
36
+ end
37
+ end