elm_install 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.rubocop.yml +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +6 -1
- data/Readme.md +44 -12
- data/bin/elm-install +8 -2
- data/docs/How it works.md +11 -5
- data/lib/elm_install/elm_package.rb +18 -8
- data/lib/elm_install/installer.rb +2 -1
- data/lib/elm_install/version.rb +1 -1
- data/package.json +30 -0
- data/packaging/Rakefile +26 -5
- data/packaging/wrapper.bat +8 -0
- data/scripts/install.js +67 -0
- data/scripts/run.js +39 -0
- data/spec/elm_package_spec.rb +44 -2
- data/spec/eml_install_spec.rb +9 -0
- data/spec/fixtures/cache.json +8 -0
- data/spec/fixtures/elm-package.json +12 -0
- data/spec/fixtures/invalid-elm-package.json +6 -0
- data/spec/fixtures/mismatched-elm-package.json +9 -0
- data/spec/fixtures/ref-cache.json +4 -0
- data/spec/git_resolver_spec.rb +21 -0
- data/spec/graph_builder_spec.rb +36 -0
- data/spec/installer_spec.rb +72 -0
- data/spec/populator_spec.rb +44 -0
- data/spec/resolver_spec.rb +11 -1
- data/spec/spec_helper.rb +3 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f7d52dc6fafa13b8d24a2892367cd419d0fc8e6
|
4
|
+
data.tar.gz: 72921b09e6525dd9644596ea3f46136d0821521d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b00b46c2cac95b3761415f7e010e0376cfb340dd162a9665f3b1f0b2dc2205dbd7cc8cc7c727c47aa2dc087877798cd0d0cc03356946c64741c3fcb539b01f
|
7
|
+
data.tar.gz: 091e3904c9a7f193105fa06bb41a6a3f71d1fa6fe78c0d00f54e7f4eb3caf037d869c33b0e7375431f1e35d4587285cb855f9bc16d9dfeb07a6e8a823f71c237
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
elm_install (0.
|
4
|
+
elm_install (0.3.0)
|
5
5
|
commander (~> 4.4, >= 4.4.2)
|
6
6
|
git (~> 1.3)
|
7
7
|
git_clone_url (~> 2.0)
|
@@ -22,6 +22,8 @@ GEM
|
|
22
22
|
thread_safe (~> 0.3, >= 0.3.1)
|
23
23
|
codeclimate-engine-rb (0.4.0)
|
24
24
|
virtus (~> 1.0)
|
25
|
+
codeclimate-test-reporter (1.0.3)
|
26
|
+
simplecov
|
25
27
|
coderay (1.1.1)
|
26
28
|
coercible (1.0.0)
|
27
29
|
descendants_tracker (~> 0.0.1)
|
@@ -69,6 +71,7 @@ GEM
|
|
69
71
|
slop (~> 3.4)
|
70
72
|
public_suffix (2.0.4)
|
71
73
|
rainbow (2.1.0)
|
74
|
+
rake (12.0.0)
|
72
75
|
reek (4.5.3)
|
73
76
|
codeclimate-engine-rb (~> 0.4.0)
|
74
77
|
parser (~> 2.3.1, >= 2.3.1.2)
|
@@ -134,8 +137,10 @@ PLATFORMS
|
|
134
137
|
ruby
|
135
138
|
|
136
139
|
DEPENDENCIES
|
140
|
+
codeclimate-test-reporter (~> 1.0.0)
|
137
141
|
elm_install!
|
138
142
|
inch (~> 0.7.1)
|
143
|
+
rake (~> 12.0)
|
139
144
|
rspec (~> 3.5)
|
140
145
|
rubocop (~> 0.46.0)
|
141
146
|
rubycritic (~> 3.1, >= 3.1.3)
|
data/Readme.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# elm-install
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/elm_install.svg)](https://badge.fury.io/rb/elm_install)
|
4
|
+
[![Npm version](https://badge.fury.io/js/elm-github-install.svg)](https://badge.fury.io/js/elm-github-install)
|
4
5
|
[![Code Climate](https://codeclimate.com/github/gdotdesign/elm-github-install/badges/gpa.svg)](https://codeclimate.com/github/gdotdesign/elm-github-install)
|
5
6
|
[![Inline docs](http://inch-ci.org/github/gdotdesign/elm-github-install.svg?branch=master)](http://inch-ci.org/github/gdotdesign/elm-github-install)
|
7
|
+
[![Build Status](https://travis-ci.org/gdotdesign/elm-github-install.svg?branch=master)](https://travis-ci.org/gdotdesign/elm-github-install)
|
6
8
|
|
7
9
|
This gem allows you to install Elm packages **directly from any Git repository
|
8
10
|
(even private ones)**, bypassing the package repository (package.elm-lang.org)
|
@@ -17,6 +19,13 @@ If you have ruby installed on your machine then you can install it directy from
|
|
17
19
|
gem install elm-install
|
18
20
|
```
|
19
21
|
|
22
|
+
If you have npm installed on your machine then you can install it directly from
|
23
|
+
[npm](https://www.npmjs.com/package/elm-github-install):
|
24
|
+
|
25
|
+
```
|
26
|
+
npm install elm-github-install -g
|
27
|
+
```
|
28
|
+
|
20
29
|
There are also dependency free versions available for every release in the
|
21
30
|
[releases page](https://github.com/gdotdesign/elm-github-install/releases).
|
22
31
|
|
@@ -38,35 +47,36 @@ replacement:
|
|
38
47
|
```
|
39
48
|
|
40
49
|
Command:
|
41
|
-
```
|
42
|
-
$ elm-install
|
50
|
+
```
|
51
|
+
$ elm-install
|
43
52
|
|
44
53
|
Resolving packages...
|
45
|
-
▶ Package:
|
46
|
-
▶ Package:
|
47
|
-
▶ Package:
|
48
|
-
▶ Package:
|
49
|
-
▶ Package:
|
54
|
+
▶ Package: https://github.com/elm-lang/core not found in cache, cloning...
|
55
|
+
▶ Package: https://github.com/elm-lang/svg not found in cache, cloning...
|
56
|
+
▶ Package: https://github.com/elm-lang/html not found in cache, cloning...
|
57
|
+
▶ Package: https://github.com/elm-lang/virtual-dom not found in cache, cloning...
|
58
|
+
▶ Package: https://github.com/elm-lang/dom not found in cache, cloning...
|
50
59
|
Solving dependencies...
|
51
60
|
Saving package cache...
|
52
61
|
● elm-lang/core - 5.0.0 (5.0.0)
|
53
62
|
● elm-lang/svg - 2.0.0 (2.0.0)
|
54
63
|
● elm-lang/dom - 1.1.1 (1.1.1)
|
55
64
|
● elm-lang/html - 2.0.0 (2.0.0)
|
56
|
-
● elm-lang/virtual-dom - 2.0.
|
65
|
+
● elm-lang/virtual-dom - 2.0.3 (2.0.3)
|
57
66
|
Packages configured successfully!
|
58
67
|
```
|
59
68
|
|
60
69
|
## Advanced Usage
|
61
70
|
Sources (urls for git repositories) can be defined in the `dependency-sources`
|
62
|
-
field in `elm-package.json` for any package defined
|
71
|
+
field in `elm-package.json` for any package defined in the `dependencies`
|
63
72
|
field. There is only one restriction: the pacakges name must match the path of
|
64
|
-
the url of the git repository, this is because it could cause conflicts
|
73
|
+
the url of the git repository, this is because it could cause conflicts with
|
74
|
+
other packages and with native code.
|
65
75
|
|
66
|
-
The source can be defined by a string or a hash containing the url and the
|
76
|
+
The source can be defined by a string (url) or a hash containing the url and the
|
67
77
|
reference (tag, commit hash, branch) to use. If a reference is defined then
|
68
78
|
the version in the `dependencies` field is ignored and the **version will be
|
69
|
-
used from the `elm-package.json` at that reference
|
79
|
+
used from the `elm-package.json` at that reference**.
|
70
80
|
|
71
81
|
```
|
72
82
|
...
|
@@ -85,3 +95,25 @@ used from the `elm-package.json` at that reference (= 2.0.0)**.
|
|
85
95
|
}
|
86
96
|
...
|
87
97
|
```
|
98
|
+
|
99
|
+
## FAQ
|
100
|
+
|
101
|
+
#### Do I need to use SSH keys?
|
102
|
+
|
103
|
+
It dependes on your use case, but for public repositories in Github or Bitbucket
|
104
|
+
it's not needed.
|
105
|
+
|
106
|
+
#### What url protocols are supported?
|
107
|
+
The following protocols can be used:
|
108
|
+
|
109
|
+
* ssh://[user@]host.xz[:port]/path/to/repo.git/
|
110
|
+
* git://host.xz[:port]/path/to/repo.git/
|
111
|
+
* http[s]://host.xz[:port]/path/to/repo.git/
|
112
|
+
* [user@]host.xz:path/to/repo.git/
|
113
|
+
|
114
|
+
#### Can I install from private repositories?
|
115
|
+
Yes private repositories are supported provided you have authentication
|
116
|
+
(for example SSH keys).
|
117
|
+
|
118
|
+
## How is it work exactly?
|
119
|
+
You can read more about it [here](docs/How it works.md).
|
data/bin/elm-install
CHANGED
@@ -11,7 +11,13 @@ program :description, 'Install Elm packages from Git repositories.'
|
|
11
11
|
command :install do |c|
|
12
12
|
c.syntax = 'elm-install install'
|
13
13
|
c.summary = 'Install Elm packages from the elm-package.json file.'
|
14
|
-
c.
|
15
|
-
|
14
|
+
c.option '--cache-directory STRING', String,
|
15
|
+
'Specifies where the cache is stored'
|
16
|
+
c.option '--verbose'
|
17
|
+
c.action do |_args, options|
|
18
|
+
ElmInstall.install verbose: options.verbose,
|
19
|
+
cache_directory: options.cache_directory
|
16
20
|
end
|
17
21
|
end
|
22
|
+
|
23
|
+
default_command :install
|
data/docs/How it works.md
CHANGED
@@ -27,14 +27,20 @@ Program flow
|
|
27
27
|
|
28
28
|
```
|
29
29
|
{
|
30
|
-
"
|
30
|
+
"https://github.com/elm-lang/core": "5.0.0 <= 6.0.0",
|
31
31
|
"git@bitbucket.com:gdotdesign/elm-ui": "development"
|
32
32
|
}
|
33
33
|
```
|
34
34
|
|
35
|
-
3. Add dependencies to the cache, skipping if the package is already added
|
35
|
+
3. Add dependencies to the cache, skipping if the package is already added:
|
36
36
|
|
37
|
-
|
37
|
+
1. If a package is not added, it is cloned from it's remote repository into
|
38
|
+
the cache directory.
|
39
|
+
|
40
|
+
2. Tags are extracted and iterated over, checking out the tag, reading and
|
41
|
+
transforming it's the `elm-package.json` and adding it's dependecies (2.)
|
42
|
+
|
43
|
+
4. Try to solve dependencies from the caches.
|
38
44
|
|
39
45
|
5. (If no solution found) Go through the packages from the cache and update
|
40
46
|
their references and if it changed update the repository (fetching new
|
@@ -44,5 +50,5 @@ Program flow
|
|
44
50
|
|
45
51
|
7. Save cache.
|
46
52
|
|
47
|
-
|
48
|
-
`elm-stuff/exact-dependecies.json
|
53
|
+
8. (If solution found) Populate `elm-stuff` and write
|
54
|
+
`elm-stuff/exact-dependecies.json`.
|
@@ -7,8 +7,8 @@ module ElmInstall
|
|
7
7
|
# @param path [String] The path for the file
|
8
8
|
#
|
9
9
|
# @return [Hash] The hash of dependenceis (url => version or ref)
|
10
|
-
def self.dependencies(path)
|
11
|
-
json = read path
|
10
|
+
def self.dependencies(path, options = { silent: true })
|
11
|
+
json = read path, options
|
12
12
|
transform_dependencies(
|
13
13
|
json['dependencies'].to_h,
|
14
14
|
json['dependency-sources'].to_h
|
@@ -22,13 +22,23 @@ module ElmInstall
|
|
22
22
|
# @param path [String] The path
|
23
23
|
#
|
24
24
|
# @return [Hash] The json
|
25
|
-
def self.read(path)
|
25
|
+
def self.read(path, options = { silent: true })
|
26
26
|
JSON.parse(File.read(path))
|
27
27
|
rescue JSON::ParserError
|
28
|
-
|
29
|
-
Process.exit
|
28
|
+
exit "Invalid JSON in file: #{path.bold}.", options
|
30
29
|
rescue Errno::ENOENT
|
31
|
-
|
30
|
+
exit "Could not find file: #{path.bold}.", options
|
31
|
+
end
|
32
|
+
|
33
|
+
# Exits the current process with the given message.
|
34
|
+
#
|
35
|
+
# @param message [String] The message
|
36
|
+
# @param options [Hash] The options
|
37
|
+
#
|
38
|
+
# @return [void]
|
39
|
+
def self.exit(message, options)
|
40
|
+
return {} if options[:silent]
|
41
|
+
Logger.arrow message
|
32
42
|
Process.exit
|
33
43
|
end
|
34
44
|
|
@@ -101,9 +111,9 @@ module ElmInstall
|
|
101
111
|
#
|
102
112
|
# @return [String] The url
|
103
113
|
def self.transform_package(key)
|
104
|
-
GitCloneUrl.parse(key).to_s
|
114
|
+
GitCloneUrl.parse(key).to_s.gsub(/\.git$/, '')
|
105
115
|
rescue
|
106
|
-
"
|
116
|
+
"https://github.com/#{key}"
|
107
117
|
end
|
108
118
|
end
|
109
119
|
end
|
@@ -111,7 +111,8 @@ module ElmInstall
|
|
111
111
|
#
|
112
112
|
# @return [Hash] The dependencies
|
113
113
|
def dependencies
|
114
|
-
@dependencies ||= ElmPackage.dependencies 'elm-package.json'
|
114
|
+
@dependencies ||= ElmPackage.dependencies 'elm-package.json',
|
115
|
+
silent: false
|
115
116
|
end
|
116
117
|
end
|
117
118
|
end
|
data/lib/elm_install/version.rb
CHANGED
data/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"name": "elm-github-install",
|
3
|
+
"version": "0.3.0",
|
4
|
+
"description": "Install Elm packages directly from Git repositories",
|
5
|
+
"scripts": {
|
6
|
+
"install": "node scripts/install.js",
|
7
|
+
"run": "node scripts/run.js"
|
8
|
+
},
|
9
|
+
"bin": {
|
10
|
+
"elm-github-install": "scripts/run.js",
|
11
|
+
"elm-install": "scripts/run.js"
|
12
|
+
},
|
13
|
+
"repository": {
|
14
|
+
"type": "git",
|
15
|
+
"url": "git+ssh://git@github.com/gdotdesign/elm-github-install.git"
|
16
|
+
},
|
17
|
+
"dependencies": {
|
18
|
+
"adm-zip": "^0.4.7",
|
19
|
+
"request": "2.74.0",
|
20
|
+
"shelljs": "0.7.5",
|
21
|
+
"tar-fs": "1.15.0",
|
22
|
+
"tmp": "^0.0.31"
|
23
|
+
},
|
24
|
+
"author": "Gusztáv Szikszai",
|
25
|
+
"license": "ISC",
|
26
|
+
"bugs": {
|
27
|
+
"url": "https://github.com/gdotdesign/elm-github-install/issues"
|
28
|
+
},
|
29
|
+
"homepage": "https://github.com/gdotdesign/elm-github-install#readme"
|
30
|
+
}
|
data/packaging/Rakefile
CHANGED
@@ -7,9 +7,14 @@ VERSION = ElmInstall::VERSION
|
|
7
7
|
TRAVELING_RUBY_VERSION = '20150715-2.2.2'.freeze
|
8
8
|
|
9
9
|
desc 'Package your app'
|
10
|
-
task package: ['package:linux:x86', 'package:linux:x86_64', 'package:osx']
|
10
|
+
task package: ['package:linux:x86', 'package:linux:x86_64', 'package:osx', 'package:win32']
|
11
11
|
|
12
12
|
namespace :package do
|
13
|
+
desc "Package your app for Windows x86"
|
14
|
+
task :win32 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-win32.tar.gz"] do
|
15
|
+
create_package("win32", :windows)
|
16
|
+
end
|
17
|
+
|
13
18
|
namespace :linux do
|
14
19
|
desc 'Package your app for Linux x86'
|
15
20
|
task x86: [
|
@@ -38,6 +43,7 @@ namespace :package do
|
|
38
43
|
|
39
44
|
desc 'Install gems to local directory'
|
40
45
|
task :bundle_install do
|
46
|
+
sh 'rm -rf vendor'
|
41
47
|
sh 'rm -rf tmp'
|
42
48
|
sh 'mkdir tmp'
|
43
49
|
sh 'cp Gemfile Gemfile.lock tmp/'
|
@@ -61,15 +67,25 @@ file "traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz" do
|
|
61
67
|
download_runtime('osx')
|
62
68
|
end
|
63
69
|
|
64
|
-
|
70
|
+
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-win32.tar.gz" do
|
71
|
+
download_runtime("win32")
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_package(target, os_type = :unix)
|
65
75
|
package_dir = "#{PACKAGE_NAME}-#{VERSION}-#{target}"
|
66
76
|
sh "rm -rf #{package_dir}"
|
67
77
|
sh "mkdir #{package_dir}"
|
68
78
|
sh "mkdir -p #{package_dir}/lib/app"
|
69
79
|
sh "mkdir #{package_dir}/lib/ruby"
|
70
80
|
sh "tar -xzf traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz -C #{package_dir}/lib/ruby"
|
71
|
-
|
72
|
-
|
81
|
+
|
82
|
+
if os_type == :unix
|
83
|
+
sh "cp wrapper.sh #{package_dir}/elm-install"
|
84
|
+
sh "chmod +x #{package_dir}/elm-install"
|
85
|
+
else
|
86
|
+
sh "cp wrapper.bat #{package_dir}/elm-install.bat"
|
87
|
+
end
|
88
|
+
|
73
89
|
sh "cp -pR vendor #{package_dir}/lib/"
|
74
90
|
sh "cp Gemfile Gemfile.lock #{package_dir}/lib/vendor/"
|
75
91
|
sh "mkdir #{package_dir}/lib/vendor/.bundle"
|
@@ -82,7 +98,12 @@ def create_package(target)
|
|
82
98
|
sh 'rm -rf lib/vendor/ruby/*/gems/*/benchmark'
|
83
99
|
|
84
100
|
unless ENV['DIR_ONLY']
|
85
|
-
|
101
|
+
if os_type == :unix
|
102
|
+
sh "tar -czf #{package_dir}.tar.gz #{package_dir}"
|
103
|
+
else
|
104
|
+
sh "zip -9r #{package_dir}.zip #{package_dir}"
|
105
|
+
end
|
106
|
+
|
86
107
|
sh "rm -rf #{package_dir}"
|
87
108
|
end
|
88
109
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
@echo off
|
2
|
+
|
3
|
+
:: Tell Bundler where the Gemfile and gems are.
|
4
|
+
set "BUNDLE_GEMFILE=%~dp0\lib\vendor\Gemfile"
|
5
|
+
set BUNDLE_IGNORE_CONFIG=
|
6
|
+
|
7
|
+
:: Run the actual binary using the bundled Ruby.
|
8
|
+
@"%~dp0\lib\ruby\bin\ruby.bat" -rbundler/setup "%~dp0\lib\vendor\ruby\2.2.0\bin\elm-install" %*
|
data/scripts/install.js
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
var request = require('request')
|
2
|
+
var shell = require('shelljs')
|
3
|
+
var AdmZip = require('adm-zip')
|
4
|
+
var tar = require('tar-fs')
|
5
|
+
var path = require('path')
|
6
|
+
var zlib = require('zlib')
|
7
|
+
var tmp = require('tmp')
|
8
|
+
var fs = require('fs')
|
9
|
+
var os = require('os')
|
10
|
+
|
11
|
+
var versionPath = path.join(__dirname, '../lib/elm_install/version.rb')
|
12
|
+
var version =
|
13
|
+
fs.readFileSync(versionPath, 'utf-8')
|
14
|
+
.match(/(\d+\.\d+\.\d+)/)[1]
|
15
|
+
|
16
|
+
var homedir = path.join(os.homedir(), '.elm-install')
|
17
|
+
var platform = os.platform()
|
18
|
+
var arch = process.arch
|
19
|
+
|
20
|
+
var prefix =
|
21
|
+
"https://github.com/gdotdesign/elm-github-install/releases/download"
|
22
|
+
|
23
|
+
var extractor = tar.extract(homedir)
|
24
|
+
|
25
|
+
var packageUrl = function(suffix) {
|
26
|
+
return [ prefix,
|
27
|
+
'v' + version,
|
28
|
+
'elm-install-' + version + '-' + suffix + '.tar.gz'
|
29
|
+
].join('/')
|
30
|
+
}
|
31
|
+
|
32
|
+
var download = function(suffix){
|
33
|
+
console.log(
|
34
|
+
'Downloading and extracting the binary from: ' + packageUrl(suffix))
|
35
|
+
|
36
|
+
request
|
37
|
+
.get(packageUrl(suffix))
|
38
|
+
.pipe(zlib.createGunzip())
|
39
|
+
.pipe(extractor)
|
40
|
+
}
|
41
|
+
|
42
|
+
if(platform == 'linux' && arch == 'x64') {
|
43
|
+
download('linux-x86_64')
|
44
|
+
} else if (platform == 'linux') {
|
45
|
+
download('linux-x86')
|
46
|
+
} else if (platform == 'darwin') {
|
47
|
+
download('osx')
|
48
|
+
} else if (platform == 'win32') {
|
49
|
+
var tmpFile = tmp.fileSync()
|
50
|
+
var url =
|
51
|
+
[ prefix,
|
52
|
+
'v' + version,
|
53
|
+
'elm-install-' + version + '-win32.zip'
|
54
|
+
].join('/')
|
55
|
+
|
56
|
+
console.log('Downloading and extracting the binary from: ' + url)
|
57
|
+
|
58
|
+
request
|
59
|
+
.get(url)
|
60
|
+
.pipe(fs.createWriteStream(tmpFile.name))
|
61
|
+
.on('finish', function(){
|
62
|
+
var zip = new AdmZip(tmpFile.name)
|
63
|
+
zip.extractAllTo(homedir)
|
64
|
+
})
|
65
|
+
} else {
|
66
|
+
console.log('Your operating system is not supported.')
|
67
|
+
}
|
data/scripts/run.js
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#! /usr/bin/env node
|
2
|
+
|
3
|
+
var exec = require('child_process').spawnSync
|
4
|
+
var path = require('path')
|
5
|
+
var os = require('os')
|
6
|
+
var fs = require('fs')
|
7
|
+
|
8
|
+
var versionPath = path.join(__dirname, '../lib/elm_install/version.rb')
|
9
|
+
var version =
|
10
|
+
fs.readFileSync(versionPath, 'utf-8')
|
11
|
+
.match(/(\d+\.\d+\.\d+)/)[1]
|
12
|
+
|
13
|
+
var homedir = path.join(os.homedir(), '.elm-install')
|
14
|
+
var platform = os.platform()
|
15
|
+
var arch = process.arch
|
16
|
+
|
17
|
+
var execute = function(suffix) {
|
18
|
+
exec(executablePath(suffix), [ process.argv.slice(2) ], { stdio: 'inherit' })
|
19
|
+
}
|
20
|
+
|
21
|
+
var executablePath = function(suffix) {
|
22
|
+
return path.join(
|
23
|
+
homedir,
|
24
|
+
[ 'elm-install-' + version + '-' + suffix ].join('/'),
|
25
|
+
'elm-install'
|
26
|
+
)
|
27
|
+
}
|
28
|
+
|
29
|
+
if(platform == 'linux' && arch == 'x64') {
|
30
|
+
execute('linux-x86_64')
|
31
|
+
} else if (platform == 'linux') {
|
32
|
+
execute('linux-x86')
|
33
|
+
} else if (platform == 'darwin') {
|
34
|
+
execute('linux-osx')
|
35
|
+
} else if (platform == 'win32') {
|
36
|
+
exec(executablePath('win32') + '.bat', [ process.argv.slice(2) ], { stdio: 'inherit' })
|
37
|
+
} else {
|
38
|
+
console.log('Your operating system is not supported.')
|
39
|
+
}
|
data/spec/elm_package_spec.rb
CHANGED
@@ -4,6 +4,48 @@ describe ElmInstall::ElmPackage do
|
|
4
4
|
subject { described_class }
|
5
5
|
|
6
6
|
let(:path) { 'spec/fixtures/elm-package.json' }
|
7
|
+
let(:invalid_path) { 'spec/fixtures/invalid-elm-package.json' }
|
8
|
+
let(:mismatch_path) { 'spec/fixtures/mismatched-elm-package.json' }
|
9
|
+
|
10
|
+
context 'package mismatch' do
|
11
|
+
subject { described_class.dependencies(mismatch_path, silent: false) }
|
12
|
+
|
13
|
+
it 'should exit' do
|
14
|
+
expect(ElmInstall::ElmPackage)
|
15
|
+
.to receive(:puts)
|
16
|
+
|
17
|
+
expect(Process).to receive(:exit)
|
18
|
+
subject
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'missing file' do
|
23
|
+
subject { described_class.dependencies('test', silent: false) }
|
24
|
+
|
25
|
+
it 'should exit' do
|
26
|
+
expect(ElmInstall::Logger)
|
27
|
+
.to receive(:arrow)
|
28
|
+
.with "Could not find file: #{'test'.bold}."
|
29
|
+
|
30
|
+
expect(Process).to receive(:exit)
|
31
|
+
|
32
|
+
expect { subject }.to raise_error(NoMethodError)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'invalid file' do
|
37
|
+
subject { described_class.dependencies(invalid_path, silent: false) }
|
38
|
+
|
39
|
+
it 'should exit' do
|
40
|
+
expect(ElmInstall::Logger)
|
41
|
+
.to receive(:arrow)
|
42
|
+
.with "Invalid JSON in file: #{invalid_path.bold}."
|
43
|
+
|
44
|
+
expect(Process).to receive(:exit)
|
45
|
+
|
46
|
+
expect { subject }.to raise_error(NoMethodError)
|
47
|
+
end
|
48
|
+
end
|
7
49
|
|
8
50
|
describe '.transform_dependencies' do
|
9
51
|
subject { described_class.dependencies(path) }
|
@@ -12,7 +54,7 @@ describe ElmInstall::ElmPackage do
|
|
12
54
|
expect(subject)
|
13
55
|
.to eq(
|
14
56
|
'git@some-domain.com:test/repo' => 'development',
|
15
|
-
'
|
57
|
+
'https://github.com/base/core' => '2.0.0 <= v < 3.0.0'
|
16
58
|
)
|
17
59
|
end
|
18
60
|
end
|
@@ -20,7 +62,7 @@ describe ElmInstall::ElmPackage do
|
|
20
62
|
describe '.transform_package' do
|
21
63
|
it 'should transform normal packages names to github ones' do
|
22
64
|
expect(subject.transform_package('test/repo'))
|
23
|
-
.to eq '
|
65
|
+
.to eq 'https://github.com/test/repo'
|
24
66
|
end
|
25
67
|
|
26
68
|
it 'should return valid git urls' do
|
data/spec/git_resolver_spec.rb
CHANGED
@@ -5,6 +5,27 @@ describe ElmInstall::GitResolver do
|
|
5
5
|
|
6
6
|
let(:uri) { 'git@github.com:test/repo' }
|
7
7
|
|
8
|
+
context 'With cache' do
|
9
|
+
subject { described_class.new directory: 'spec/fixtures' }
|
10
|
+
|
11
|
+
describe '#save' do
|
12
|
+
it 'should save cache' do
|
13
|
+
expect(File).to receive(:binwrite)
|
14
|
+
subject.save
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#clear' do
|
19
|
+
it 'should clear the cache' do
|
20
|
+
expect do
|
21
|
+
subject.clear
|
22
|
+
end.to change {
|
23
|
+
subject.instance_variable_get('@check_cache').keys.count
|
24
|
+
}.from(2).to(0)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
8
29
|
describe '.repository' do
|
9
30
|
let(:refs) { {} }
|
10
31
|
let(:repo) { Git.init CACHE_DIRECTORY }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ElmInstall::GraphBuilder do
|
4
|
+
let(:cache) { ElmInstall::Cache.new(directory: 'spec/fixtures') }
|
5
|
+
|
6
|
+
subject { described_class.new cache, verbose: true }
|
7
|
+
|
8
|
+
describe '.graph_from_cache' do
|
9
|
+
it 'should generate a graph from cache' do
|
10
|
+
graph = described_class.graph_from_cache(cache)
|
11
|
+
names = graph.artifacts.map(&:name)
|
12
|
+
expect(names)
|
13
|
+
.to eq(['https://github.com/base/core',
|
14
|
+
'https://github.com/test/test'])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.add_version' do
|
19
|
+
it 'should rescue from errors' do
|
20
|
+
expect(subject).to receive(:puts)
|
21
|
+
|
22
|
+
subject.send(:add_version, 'test', 'asd', {})
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.add_dependency' do
|
27
|
+
let(:artifact) { double :artifact }
|
28
|
+
|
29
|
+
it 'should rescue from errors' do
|
30
|
+
expect(subject).to receive(:puts)
|
31
|
+
expect(artifact).to receive(:depends).and_raise 'test'
|
32
|
+
|
33
|
+
subject.send(:add_dependency, artifact, 'asd', {})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ElmInstall::Installer do
|
4
|
+
subject { described_class.new cache_directory: CACHE_DIRECTORY }
|
5
|
+
|
6
|
+
let(:main_package) do
|
7
|
+
{ dependencies: { 'base/core' => '1.0.0 <= v < 2.0.0' } }.to_json
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:base_package) do
|
11
|
+
{ dependencies: {} }.to_json
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'sucessfull install' do
|
15
|
+
before do
|
16
|
+
expect(File)
|
17
|
+
.to receive(:read)
|
18
|
+
.and_return(main_package, base_package, base_package)
|
19
|
+
|
20
|
+
expect_any_instance_of(ElmInstall::Resolver)
|
21
|
+
.to receive(:add_constraints)
|
22
|
+
|
23
|
+
expect(subject)
|
24
|
+
.to receive(:puts)
|
25
|
+
.exactly(4).times
|
26
|
+
|
27
|
+
expect(File)
|
28
|
+
.to receive(:binwrite)
|
29
|
+
.with('spec/fixtures/cache/ref-cache.json', any_args)
|
30
|
+
|
31
|
+
expect(File)
|
32
|
+
.to receive(:binwrite)
|
33
|
+
.with('spec/fixtures/cache/cache.json', any_args)
|
34
|
+
|
35
|
+
expect(File)
|
36
|
+
.to receive(:binwrite)
|
37
|
+
.with('elm-stuff/exact-dependencies.json', any_args)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should install dependencies' do
|
41
|
+
subject.install
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'unsuccessfull install' do
|
46
|
+
before do
|
47
|
+
expect(File)
|
48
|
+
.to receive(:read)
|
49
|
+
.and_return(main_package, base_package, base_package)
|
50
|
+
|
51
|
+
expect_any_instance_of(ElmInstall::Resolver)
|
52
|
+
.to receive(:add_constraints)
|
53
|
+
.exactly(2).times
|
54
|
+
|
55
|
+
expect(subject)
|
56
|
+
.to receive(:populate_elm_stuff)
|
57
|
+
.exactly(2).times
|
58
|
+
.and_raise(Solve::Errors::NoSolutionError)
|
59
|
+
|
60
|
+
expect(ElmInstall::Logger)
|
61
|
+
.to receive(:arrow)
|
62
|
+
|
63
|
+
expect(subject)
|
64
|
+
.to receive(:puts)
|
65
|
+
.exactly(4).times
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should install dependencies' do
|
69
|
+
subject.install
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ElmInstall::Populator do
|
4
|
+
let(:git_resolver) { ElmInstall::GitResolver.new directory: CACHE_DIRECTORY }
|
5
|
+
|
6
|
+
let(:solution) do
|
7
|
+
{
|
8
|
+
'https://github.com/base/core' => '1.0.0',
|
9
|
+
'https://github.com/test/repo' => '1.0.0+development'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:repo) { double :repository, checkout: true }
|
14
|
+
|
15
|
+
subject { described_class.new git_resolver }
|
16
|
+
|
17
|
+
it 'should populate elm-stuff' do
|
18
|
+
expect(git_resolver)
|
19
|
+
.to receive(:repository)
|
20
|
+
.exactly(2).times
|
21
|
+
.and_return repo
|
22
|
+
|
23
|
+
expect(ElmInstall::Logger)
|
24
|
+
.to receive(:dot)
|
25
|
+
.exactly(2)
|
26
|
+
.times
|
27
|
+
|
28
|
+
expect(FileUtils)
|
29
|
+
.to receive(:cp_r)
|
30
|
+
.with(
|
31
|
+
'spec/fixtures/cache/github.com/base/core/.',
|
32
|
+
'elm-stuff/packages/base/core/1.0.0'
|
33
|
+
)
|
34
|
+
|
35
|
+
expect(FileUtils)
|
36
|
+
.to receive(:cp_r)
|
37
|
+
.with(
|
38
|
+
'spec/fixtures/cache/github.com/test/repo/.',
|
39
|
+
'elm-stuff/packages/test/repo/1.0.0'
|
40
|
+
)
|
41
|
+
|
42
|
+
subject.populate(solution)
|
43
|
+
end
|
44
|
+
end
|
data/spec/resolver_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe ElmInstall::Resolver do
|
|
37
37
|
|
38
38
|
expect(ElmInstall::Logger)
|
39
39
|
.to receive(:arrow)
|
40
|
-
.with "Package: #{'
|
40
|
+
.with "Package: #{'https://github.com/base/core'.bold} not found in \
|
41
41
|
cache, cloning...".gsub(/\s+/, ' ')
|
42
42
|
|
43
43
|
allow_any_instance_of(Git::Remote)
|
@@ -62,4 +62,14 @@ describe ElmInstall::Resolver do
|
|
62
62
|
'git@github.com:base/core' => '1.0.0 <= v < 2.0.0'
|
63
63
|
)
|
64
64
|
end
|
65
|
+
|
66
|
+
describe '#elm_dependencies' do
|
67
|
+
it 'should return empty hash on error' do
|
68
|
+
expect(ElmInstall::ElmPackage)
|
69
|
+
.to receive(:read)
|
70
|
+
.and_raise 'test'
|
71
|
+
|
72
|
+
expect(subject.elm_dependencies('test')).to eq({})
|
73
|
+
end
|
74
|
+
end
|
65
75
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,15 +4,17 @@ CACHE_DIRECTORY = 'spec/fixtures/cache'.freeze
|
|
4
4
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.before do
|
7
|
-
FileUtils.
|
7
|
+
FileUtils.mkdir_p CACHE_DIRECTORY
|
8
8
|
end
|
9
9
|
|
10
10
|
config.after do
|
11
11
|
FileUtils.rm_rf CACHE_DIRECTORY
|
12
|
+
FileUtils.rm_rf 'elm-stuff'
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
SimpleCov.start do
|
17
|
+
add_filter '/vendor/'
|
16
18
|
add_filter '/spec/'
|
17
19
|
end
|
18
20
|
|
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: 0.
|
4
|
+
version: 0.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:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- ".rubocop.yml"
|
135
135
|
- ".ruby-gemset"
|
136
136
|
- ".ruby-version"
|
137
|
+
- ".travis.yml"
|
137
138
|
- Gemfile
|
138
139
|
- Gemfile.lock
|
139
140
|
- Rakefile
|
@@ -153,14 +154,27 @@ files:
|
|
153
154
|
- lib/elm_install/resolver.rb
|
154
155
|
- lib/elm_install/utils.rb
|
155
156
|
- lib/elm_install/version.rb
|
157
|
+
- package.json
|
156
158
|
- packaging/.ruby-gemset
|
157
159
|
- packaging/Gemfile
|
158
160
|
- packaging/Gemfile.lock
|
159
161
|
- packaging/Rakefile
|
160
162
|
- packaging/bundler-config
|
163
|
+
- packaging/wrapper.bat
|
161
164
|
- packaging/wrapper.sh
|
165
|
+
- scripts/install.js
|
166
|
+
- scripts/run.js
|
162
167
|
- spec/elm_package_spec.rb
|
168
|
+
- spec/eml_install_spec.rb
|
169
|
+
- spec/fixtures/cache.json
|
170
|
+
- spec/fixtures/elm-package.json
|
171
|
+
- spec/fixtures/invalid-elm-package.json
|
172
|
+
- spec/fixtures/mismatched-elm-package.json
|
173
|
+
- spec/fixtures/ref-cache.json
|
163
174
|
- spec/git_resolver_spec.rb
|
175
|
+
- spec/graph_builder_spec.rb
|
176
|
+
- spec/installer_spec.rb
|
177
|
+
- spec/populator_spec.rb
|
164
178
|
- spec/resolver_spec.rb
|
165
179
|
- spec/spec_helper.rb
|
166
180
|
- spec/utils_spec.rb
|