kmc 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +22 -0
- data/README.md +141 -0
- data/Rakefile +2 -0
- data/bin/kmc +20 -0
- data/kmc.gemspec +26 -0
- data/lib/kmc.rb +27 -0
- data/lib/kmc/configuration.rb +67 -0
- data/lib/kmc/download_url.rb +80 -0
- data/lib/kmc/git_adapter.rb +71 -0
- data/lib/kmc/package.rb +142 -0
- data/lib/kmc/package_attrs.rb +69 -0
- data/lib/kmc/package_downloads.rb +122 -0
- data/lib/kmc/package_dsl.rb +13 -0
- data/lib/kmc/package_utils.rb +29 -0
- data/lib/kmc/packages/lack_luster_labs.rb +22 -0
- data/lib/kmc/page_fetcher.js +47 -0
- data/lib/kmc/post_processors/module_manager_resolver.rb +32 -0
- data/lib/kmc/refresher.rb +36 -0
- data/lib/kmc/user_interface.rb +195 -0
- data/lib/kmc/util.rb +11 -0
- data/lib/kmc/version.rb +3 -0
- data/lib/kmc/versioner.rb +70 -0
- data/lib/kmc/web/app.rb +42 -0
- data/lib/kmc/web/public/css/main.css +69 -0
- data/lib/kmc/web/public/css/normalize.css +527 -0
- data/lib/kmc/web/public/index.html +107 -0
- data/lib/kmc/web/public/js/main.js +125 -0
- data/lib/kmc/web/public/js/plugins.js +24 -0
- data/lib/kmc/web/public/js/vendor/jquery-1.10.2.min.js +6 -0
- data/lib/kmc/web/public/js/vendor/modernizr-2.6.2.min.js +4 -0
- data/lib/kmc/web/public/js/vendor/underscore.js +5 -0
- data/package_generator.rb +197 -0
- data/spec/download_url_spec.rb +69 -0
- data/spec/fixtures/example_box.html +165 -0
- data/spec/fixtures/example_dropbox.com.html +114 -0
- data/spec/fixtures/example_mediafire.html +101 -0
- data/spec/package_spec.rb +113 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/versioner_spec.rb +69 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ed54db50ea2e8db76df2289b073b2d31914ba6b1
|
4
|
+
data.tar.gz: 702b34da5afebebac59a3a1232f02cc8acea4264
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d36702d7dffd070f88dcf26c033cdcb95b955e84c3852b91aae8ce216509d0838d82dda01b7b26e927ccf4169ac3ddfb7d78151e2998e5a7e042fa7b75c1b86a
|
7
|
+
data.tar.gz: 4c55bcce9a419fa84c71490767290d251e3dac607e6ac2cb5911f033666224de6edd0f5aa370c7c20ad7a2cd1a1cbc59053130aae85b262d66c496367c6accfa
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'bundler', '~> 1.6'
|
7
|
+
gem 'rake'
|
8
|
+
gem 'rspec', '~> 2.14'
|
9
|
+
gem 'webmock'
|
10
|
+
gem 'pry'
|
11
|
+
gem 'octokit'
|
12
|
+
gem 'colorize'
|
13
|
+
gem 'activesupport'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem 'fakefs', require: 'fakefs/safe'
|
18
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ulysse Carion
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# KMC
|
2
|
+
|
3
|
+
A simple package manager for Kerbal Space Program. Install any mod by simply
|
4
|
+
saying `kmc install name-of-mod`. For example, install Mechjeb by issuing the
|
5
|
+
command:
|
6
|
+
|
7
|
+
```
|
8
|
+
kmc install mechjeb
|
9
|
+
```
|
10
|
+
|
11
|
+
*Note:* KMC is still in active development, and is not meant for serious use
|
12
|
+
unless you're brave or stupid.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
*Note:* KMC is indeed not super easy to install if you're not used to
|
17
|
+
installing things by hand. When KMC is ready for "production" use, one-click
|
18
|
+
installers will be added.
|
19
|
+
|
20
|
+
KMC has three dependencies, all of which are currently expected to be on your
|
21
|
+
`PATH`. They are:
|
22
|
+
|
23
|
+
* Ruby version 2.0+,
|
24
|
+
* Git, and
|
25
|
+
* PhantomJS
|
26
|
+
|
27
|
+
### Installing Ruby
|
28
|
+
|
29
|
+
KMC has been tested on Ruby 2.0.0, and it is recommended that you use Ruby
|
30
|
+
2.0.0 or greater. Check your version of Ruby using:
|
31
|
+
|
32
|
+
```sh
|
33
|
+
ruby -v
|
34
|
+
```
|
35
|
+
|
36
|
+
If you need to update Ruby, use one of the following tools:
|
37
|
+
|
38
|
+
* *Mac*: [RVM](https://rvm.io/) is the recommended tool for the job, but not
|
39
|
+
everyone is comfortable with it. If you prefer, you may use
|
40
|
+
[Homebrew](http://brew.sh) and install Ruby 2.0 with: `brew install ruby20`.
|
41
|
+
* *Windows*: Install Ruby 2.0+ with [Ruby Installer](http://rubyinstaller.org/).
|
42
|
+
* *Linux*: Use [RVM](https://rvm.io/).
|
43
|
+
|
44
|
+
Verify that you're running Ruby 2.0+ by running:
|
45
|
+
|
46
|
+
```sh
|
47
|
+
ruby -v
|
48
|
+
```
|
49
|
+
|
50
|
+
### Installing Git
|
51
|
+
|
52
|
+
* *Mac*: Use the [Mac Git installer][mac-git], or use Homebrew. Remember to
|
53
|
+
check any box asking to add Git to your path.
|
54
|
+
* *Windows*: Install Git using [this installer][win-git]. Remember to check any
|
55
|
+
box asking to add Git to your path.
|
56
|
+
* *Linux*: Run the command:
|
57
|
+
* `yum install git-core` on Fedora, or
|
58
|
+
* `apt-get install git` on Debian / Ubuntu.
|
59
|
+
|
60
|
+
Verify that Git is installed properly by running:
|
61
|
+
|
62
|
+
```sh
|
63
|
+
git --version
|
64
|
+
```
|
65
|
+
|
66
|
+
### Installing PhantomJS
|
67
|
+
|
68
|
+
Install PhantomJS [here][phantom]. You will need to add PhantomJS to your path
|
69
|
+
manually. Verify that PhantomJS is installed properly by running:
|
70
|
+
|
71
|
+
```sh
|
72
|
+
phantomjs --version
|
73
|
+
```
|
74
|
+
|
75
|
+
### Installing KMC itself
|
76
|
+
|
77
|
+
Just run:
|
78
|
+
|
79
|
+
```sh
|
80
|
+
gem install kmc
|
81
|
+
```
|
82
|
+
|
83
|
+
And it'll be ready to go.
|
84
|
+
|
85
|
+
## Usage
|
86
|
+
|
87
|
+
### First run
|
88
|
+
|
89
|
+
First, you have to point KMC to your Kerbal Space Program installation directory:
|
90
|
+
|
91
|
+
```
|
92
|
+
kmc init "your-ksp-path"
|
93
|
+
```
|
94
|
+
|
95
|
+
`your-ksp-path` varies with the operating system and game installation. For a
|
96
|
+
Steam-installed game it should be:
|
97
|
+
|
98
|
+
* on OS X: `kmc init "~/Library/Application Support/Steam/SteamApps/common/Kerbal Space Program/"`
|
99
|
+
* on Windows: `kmc init "C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program"`
|
100
|
+
* on Linux: `kmc init "~/Steam/SteamApps/common/Kerbal Space Program/"`
|
101
|
+
|
102
|
+
Then, KMC will be ready to use.
|
103
|
+
|
104
|
+
### Mod management
|
105
|
+
|
106
|
+
Install any command by running:
|
107
|
+
|
108
|
+
```
|
109
|
+
kmc install name-of-the-mod-goes-here
|
110
|
+
```
|
111
|
+
|
112
|
+
Uninstall any mod by running:
|
113
|
+
|
114
|
+
```
|
115
|
+
kmc uninstall name-of-the-mod-goes-here
|
116
|
+
```
|
117
|
+
|
118
|
+
You can install multiple mods by separating the names by spaces:
|
119
|
+
|
120
|
+
```
|
121
|
+
kmc install mod-a mod-b mod-c
|
122
|
+
```
|
123
|
+
|
124
|
+
You can ask KMC what mods it's installed by running:
|
125
|
+
|
126
|
+
```
|
127
|
+
kmc list
|
128
|
+
```
|
129
|
+
|
130
|
+
### A complete example
|
131
|
+
|
132
|
+
Almost all of the mods Scott Manley uses in Interstellar Quest are available
|
133
|
+
through KMC. You can install them all by running:
|
134
|
+
|
135
|
+
```
|
136
|
+
kmc install active-texture-management b9 kerbal-alarm-clock kw-rocketry ksp-interstellar ferram deadly-reentry kethane infernal-robotics distant-object-enhancement better-atmospheres remote-tech-2 tac-life-support enhanced-navball kerbal-joint-reinforcement docking-port-alignment-indicator safe-chute kerbal-attachment-system real-chute tac-fuel-balancer
|
137
|
+
```
|
138
|
+
|
139
|
+
[mac-git]: http://sourceforge.net/projects/git-osx-installer/
|
140
|
+
[win-git]: http://git-scm.com/download/win
|
141
|
+
[phantom]: http://phantomjs.org/download.html
|
data/Rakefile
ADDED
data/bin/kmc
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'kmc'
|
4
|
+
|
5
|
+
Kmc.configure do |config|
|
6
|
+
config.verbose = true
|
7
|
+
end
|
8
|
+
|
9
|
+
case ARGV.shift
|
10
|
+
when 'init'
|
11
|
+
Kmc::UserInterface.init(ARGV)
|
12
|
+
when 'install'
|
13
|
+
Kmc::UserInterface.install(ARGV)
|
14
|
+
when 'uninstall'
|
15
|
+
Kmc::UserInterface.uninstall(ARGV)
|
16
|
+
when 'list'
|
17
|
+
Kmc::UserInterface.list(ARGV)
|
18
|
+
when 'server'
|
19
|
+
Kmc::UserInterface.server(ARGV)
|
20
|
+
end
|
data/kmc.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kmc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kmc"
|
8
|
+
spec.version = Kmc::VERSION
|
9
|
+
spec.authors = ["Ulysse Carion"]
|
10
|
+
spec.email = ["ulyssecarion@gmail.com"]
|
11
|
+
spec.summary = %q{The simple package manager for Kerbal Space Program.}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "rubyzip"
|
21
|
+
spec.add_dependency "httparty"
|
22
|
+
spec.add_dependency "nokogiri"
|
23
|
+
spec.add_dependency "damerau-levenshtein"
|
24
|
+
spec.add_dependency "sinatra"
|
25
|
+
spec.add_dependency "thin"
|
26
|
+
end
|
data/lib/kmc.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'kmc/configuration'
|
2
|
+
require 'kmc/package_dsl'
|
3
|
+
require 'kmc/package_attrs'
|
4
|
+
require 'kmc/package_downloads'
|
5
|
+
require 'kmc/package'
|
6
|
+
require 'kmc/versioner'
|
7
|
+
require 'kmc/git_adapter'
|
8
|
+
require 'kmc/download_url'
|
9
|
+
require 'kmc/user_interface'
|
10
|
+
require 'kmc/refresher'
|
11
|
+
require 'kmc/web/app'
|
12
|
+
require 'kmc/util'
|
13
|
+
require 'kmc/version'
|
14
|
+
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
module Kmc
|
18
|
+
class << self
|
19
|
+
def config
|
20
|
+
@config ||= Configuration::Configurator.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure
|
24
|
+
yield(config)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Kmc
|
2
|
+
module Configuration
|
3
|
+
class Configurator
|
4
|
+
attr_accessor :verbose, :post_processors, :output_method, :packages_url
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@verbose = false
|
8
|
+
@post_processors = [Kmc::PostProcessors::ModuleManagerResolver]
|
9
|
+
@output_method = Proc.new { |str| puts str }
|
10
|
+
@packages_url = "https://github.com/kmc/packages/archive/master.zip"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def save_ksp_path(path)
|
16
|
+
write_config(ksp_path: path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_ksp_path
|
20
|
+
read_config[:ksp_path]
|
21
|
+
end
|
22
|
+
|
23
|
+
def cache_dir
|
24
|
+
read_config[:cache_dir]
|
25
|
+
end
|
26
|
+
|
27
|
+
def packages_path
|
28
|
+
File.join(kmc_path, 'packages', 'packages')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def write_config(opts)
|
34
|
+
ensure_config_exists!
|
35
|
+
|
36
|
+
config_to_write = JSON.pretty_generate(read_config.merge(opts))
|
37
|
+
File.open(config_path, "w") do |file|
|
38
|
+
file.write config_to_write
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def read_config
|
43
|
+
ensure_config_exists!
|
44
|
+
|
45
|
+
config = File.read(config_path)
|
46
|
+
if config.empty?
|
47
|
+
{}
|
48
|
+
else
|
49
|
+
JSON.parse(config, symbolize_names: true)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def ensure_config_exists!
|
54
|
+
FileUtils.mkdir_p(kmc_path)
|
55
|
+
FileUtils.touch(config_path)
|
56
|
+
end
|
57
|
+
|
58
|
+
def config_path
|
59
|
+
File.join(kmc_path, 'config.json')
|
60
|
+
end
|
61
|
+
|
62
|
+
def kmc_path
|
63
|
+
File.join(Dir.home, ".kmc")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Kmc
|
4
|
+
class DownloadUrl < Struct.new(:url)
|
5
|
+
def resolve_download_url
|
6
|
+
if mediafire?
|
7
|
+
extract_mediafire_url
|
8
|
+
elsif box?
|
9
|
+
extract_box_url
|
10
|
+
elsif dropbox?
|
11
|
+
extract_dropbox_url
|
12
|
+
elsif curseforge?
|
13
|
+
extract_curseforge_url
|
14
|
+
else
|
15
|
+
url
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_known_resolver?
|
20
|
+
mediafire? || box? || dropbox? || curseforge?
|
21
|
+
end
|
22
|
+
|
23
|
+
def mediafire?
|
24
|
+
url =~ /mediafire/
|
25
|
+
end
|
26
|
+
|
27
|
+
def box?
|
28
|
+
url =~ /app\.box\.com/
|
29
|
+
end
|
30
|
+
|
31
|
+
def dropbox?
|
32
|
+
url =~ /dropbox\.com/
|
33
|
+
end
|
34
|
+
|
35
|
+
def curseforge?
|
36
|
+
url =~ /curseforge/
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def extract_mediafire_url
|
42
|
+
rendered_page.css('.download_link a').first['href']
|
43
|
+
end
|
44
|
+
|
45
|
+
def extract_dropbox_url
|
46
|
+
rendered_page.css('#default_content_download_button').first['href']
|
47
|
+
end
|
48
|
+
|
49
|
+
def extract_curseforge_url
|
50
|
+
rendered_html("#{url}/files/latest").strip
|
51
|
+
end
|
52
|
+
|
53
|
+
def extract_box_url
|
54
|
+
raw_html = HTTParty.get(url)
|
55
|
+
|
56
|
+
shared_name = url.split("/").last
|
57
|
+
file_id = raw_html.scan(/itemTypedID: \"(f_\d+)\"/)[0][0]
|
58
|
+
|
59
|
+
box_intermediate_url(shared_name, file_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
def box_intermediate_url(shared_name, file_id)
|
63
|
+
base = "https://app.box.com/index.php?rm=box_download_shared_file"
|
64
|
+
shared_name_part = "&shared_name=#{shared_name}"
|
65
|
+
file_id_part = "&file_id=#{file_id}"
|
66
|
+
|
67
|
+
base + shared_name_part + file_id_part
|
68
|
+
end
|
69
|
+
|
70
|
+
def rendered_page(url = self.url)
|
71
|
+
Nokogiri::HTML(rendered_html(url))
|
72
|
+
end
|
73
|
+
|
74
|
+
def rendered_html(url)
|
75
|
+
Dir.chdir(File.dirname(__FILE__)) do
|
76
|
+
`phantomjs page_fetcher.js #{url}`
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|