mmi 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +675 -0
- data/README.adoc +57 -19
- data/exe/mmi +13 -13
- data/lib/mmi/assets_processor.rb +29 -16
- data/lib/mmi/cached_download.rb +59 -0
- data/lib/mmi/github_api.rb +11 -0
- data/lib/mmi/interactive/assets.rb +208 -0
- data/lib/mmi/interactive/modloader.rb +139 -0
- data/lib/mmi/interactive/updater.rb +25 -138
- data/lib/mmi/interactive.rb +1 -2
- data/lib/mmi/mod_file_processor.rb +42 -28
- data/lib/mmi/modloader/fabric.rb +65 -36
- data/lib/mmi/modloader/none.rb +3 -1
- data/lib/mmi/modrinth_api.rb +18 -0
- data/lib/mmi/option_attributes.rb +38 -0
- data/lib/mmi/semver.rb +21 -0
- data/lib/mmi/source/github.rb +28 -28
- data/lib/mmi/source/modrinth.rb +83 -0
- data/lib/mmi/source/url.rb +59 -0
- data/lib/mmi/version.rb +1 -1
- data/lib/mmi.rb +2 -8
- metadata +75 -21
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
require 'mmi/modrinth_api'
|
5
|
+
require 'mmi/option_attributes'
|
6
|
+
|
7
|
+
module Mmi
|
8
|
+
module Source
|
9
|
+
class Modrinth
|
10
|
+
include Mmi::OptionAttributes
|
11
|
+
|
12
|
+
opt_accessor :name
|
13
|
+
opt_accessor :version
|
14
|
+
opt_accessor :version_file
|
15
|
+
|
16
|
+
opt_accessor :install_dir
|
17
|
+
opt_accessor :filename
|
18
|
+
|
19
|
+
def initialize(options)
|
20
|
+
@options = options
|
21
|
+
|
22
|
+
parse!
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse!
|
26
|
+
if self.name
|
27
|
+
if self.version
|
28
|
+
if self.version_file
|
29
|
+
if self.install_dir
|
30
|
+
# Pass.
|
31
|
+
else
|
32
|
+
raise Mmi::MissingAttributeError, 'Missing "source.install_dir" from asset.'
|
33
|
+
end
|
34
|
+
else
|
35
|
+
raise Mmi::MissingAttributeError, 'Missing "source.version_file" from asset.'
|
36
|
+
end
|
37
|
+
else
|
38
|
+
raise Mmi::MissingAttributeError, 'Missing "source.version" from asset.'
|
39
|
+
end
|
40
|
+
else
|
41
|
+
raise Mmi::MissingAttributeError, 'Missing "source.name" from asset.'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def cached_mod_id
|
46
|
+
@cached_mod_id ||= Mmi::ModrinthApi.mod(self.name)['id']
|
47
|
+
end
|
48
|
+
|
49
|
+
def cached_mod_versions
|
50
|
+
@cached_mod_versions ||= Mmi::ModrinthApi.mod_versions(cached_mod_id)
|
51
|
+
end
|
52
|
+
|
53
|
+
def download_url
|
54
|
+
cached_mod_versions.select do |version|
|
55
|
+
version['name'] == self.version
|
56
|
+
end.first['files'].select do |files|
|
57
|
+
files['filename'] == self.version_file
|
58
|
+
end.first['url'].gsub(/ /, '%20')
|
59
|
+
end
|
60
|
+
|
61
|
+
def install(dir)
|
62
|
+
install_dir = File.expand_path(self.install_dir, dir)
|
63
|
+
filepath = File.join(install_dir, self.filename || self.version_file)
|
64
|
+
|
65
|
+
Mmi.info "Downloading #{download_url.inspect} into #{filepath.inspect}."
|
66
|
+
|
67
|
+
FileUtils.mkdir_p(install_dir)
|
68
|
+
|
69
|
+
begin
|
70
|
+
stream = URI.parse(download_url).open
|
71
|
+
|
72
|
+
IO.copy_stream(stream, filepath)
|
73
|
+
rescue OpenURI::HTTPError => e
|
74
|
+
Mmi.fail! "Error when requesting asset.\n#{e.inspect}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def display_name
|
79
|
+
"https://modrinth.com/mod/#{name}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
require 'mmi/option_attributes'
|
5
|
+
|
6
|
+
module Mmi
|
7
|
+
module Source
|
8
|
+
class Url
|
9
|
+
include Mmi::OptionAttributes
|
10
|
+
|
11
|
+
opt_accessor :url
|
12
|
+
opt_accessor :install_dir
|
13
|
+
opt_accessor :filename
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
@options = options
|
17
|
+
|
18
|
+
parse!
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse!
|
22
|
+
if self.url
|
23
|
+
if self.install_dir
|
24
|
+
# Pass.
|
25
|
+
else
|
26
|
+
raise Mmi::MissingAttributeError, 'Missing "source.install_dir" from asset.'
|
27
|
+
end
|
28
|
+
else
|
29
|
+
raise Mmi::MissingAttributeError, 'Missing "source.name" from asset.'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def download_uri
|
34
|
+
@download_uri ||= URI.parse(url)
|
35
|
+
end
|
36
|
+
|
37
|
+
def install(dir)
|
38
|
+
install_dir = File.expand_path(self.install_dir, dir)
|
39
|
+
filepath = File.join(install_dir, self.filename || File.basename(download_uri.path))
|
40
|
+
|
41
|
+
Mmi.info "Downloading #{url.inspect} into #{filepath.inspect}."
|
42
|
+
|
43
|
+
FileUtils.mkdir_p(install_dir)
|
44
|
+
|
45
|
+
begin
|
46
|
+
stream = download_uri.open
|
47
|
+
|
48
|
+
IO.copy_stream(stream, filepath)
|
49
|
+
rescue OpenURI::HTTPError => e
|
50
|
+
Mmi.fail! "Error when requesting asset.\n#{e.inspect}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def display_name
|
55
|
+
url
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/mmi/version.rb
CHANGED
data/lib/mmi.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
require 'semver'
|
2
|
-
require 'open-uri'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'digest'
|
5
|
-
require 'github_api'
|
6
|
-
|
7
1
|
require 'mmi/version'
|
8
2
|
require 'mmi/mod_file_processor'
|
9
3
|
|
@@ -24,7 +18,7 @@ module Mmi
|
|
24
18
|
class InvalidAttributeError < ValidationError; end
|
25
19
|
|
26
20
|
def self.debug(text)
|
27
|
-
if ENV['MMI_ENV']=='dev'
|
21
|
+
if ENV['MMI_ENV'] == 'dev'
|
28
22
|
puts text
|
29
23
|
end
|
30
24
|
end
|
@@ -38,7 +32,7 @@ module Mmi
|
|
38
32
|
end
|
39
33
|
|
40
34
|
def self.fail!(text)
|
41
|
-
|
35
|
+
Kernel.warn text
|
42
36
|
Kernel.exit 1
|
43
37
|
end
|
44
38
|
end
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mmi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- expeehaa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: cli-ui
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.11'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: octokit
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.22'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '4.22'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.13'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0.13'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,19 +81,61 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '13.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3.10'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3.10'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: warbler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.0'
|
97
139
|
description:
|
98
140
|
email:
|
99
141
|
- expeehaa@outlook.com
|
@@ -102,20 +144,32 @@ executables:
|
|
102
144
|
extensions: []
|
103
145
|
extra_rdoc_files: []
|
104
146
|
files:
|
147
|
+
- LICENSE
|
105
148
|
- README.adoc
|
106
149
|
- exe/mmi
|
107
150
|
- lib/mmi.rb
|
108
151
|
- lib/mmi/assets_processor.rb
|
152
|
+
- lib/mmi/cached_download.rb
|
153
|
+
- lib/mmi/github_api.rb
|
109
154
|
- lib/mmi/interactive.rb
|
155
|
+
- lib/mmi/interactive/assets.rb
|
156
|
+
- lib/mmi/interactive/modloader.rb
|
110
157
|
- lib/mmi/interactive/updater.rb
|
111
158
|
- lib/mmi/mod_file_processor.rb
|
112
159
|
- lib/mmi/modloader/fabric.rb
|
113
160
|
- lib/mmi/modloader/none.rb
|
161
|
+
- lib/mmi/modrinth_api.rb
|
162
|
+
- lib/mmi/option_attributes.rb
|
163
|
+
- lib/mmi/semver.rb
|
114
164
|
- lib/mmi/source/github.rb
|
165
|
+
- lib/mmi/source/modrinth.rb
|
166
|
+
- lib/mmi/source/url.rb
|
115
167
|
- lib/mmi/version.rb
|
116
168
|
homepage: https://github.com/expeehaa/mmi
|
117
|
-
licenses:
|
118
|
-
|
169
|
+
licenses:
|
170
|
+
- GPL-3.0-only
|
171
|
+
metadata:
|
172
|
+
rubygems_mfa_required: 'true'
|
119
173
|
post_install_message:
|
120
174
|
rdoc_options: []
|
121
175
|
require_paths:
|
@@ -124,14 +178,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
178
|
requirements:
|
125
179
|
- - ">="
|
126
180
|
- !ruby/object:Gem::Version
|
127
|
-
version: '0'
|
181
|
+
version: '3.0'
|
128
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
183
|
requirements:
|
130
184
|
- - ">="
|
131
185
|
- !ruby/object:Gem::Version
|
132
186
|
version: '0'
|
133
187
|
requirements: []
|
134
|
-
rubygems_version: 3.
|
188
|
+
rubygems_version: 3.3.3
|
135
189
|
signing_key:
|
136
190
|
specification_version: 4
|
137
191
|
summary: Program to install minecraft modloaders, mods and other assets through a
|