lumia-server 1.0.0.alpha → 1.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
  SHA256:
3
- metadata.gz: d18f96514ed0b5f4be57bc73ccbd1b1fcb1189449031c13e186bd77cf6227378
4
- data.tar.gz: a41b22d0d1e5da6d6c94521341877226dcec30ebbff15757129689d27aa276bb
3
+ metadata.gz: 400fdbe318d19f7a36aca26dd57554007d5699e48bc14d5a3134c0784e182568
4
+ data.tar.gz: f3f5dc13f96af6935f6fc12bc513e15d3f9eb4e8a633d3753a28204cbf83b47a
5
5
  SHA512:
6
- metadata.gz: 4952b591284c644a6976caa7f61e83e47ce926f1abd60c397b6e6cee2c8b315a718e067b18404e8c62c69dc8bb0192e26b48c33f9f36ea9a19aa8bd23da1bb42
7
- data.tar.gz: a883a4ffde1777211fab658ce2331453a0a32cfb7ab75c299a12b86b6bb6c63a81db1ac842e90b0b855b2efd3284b261aa8dfea98a1f4cbad6af7b3ab3610612
6
+ metadata.gz: 51c25b90a6e2c9c37c9bb62fdee92ace32a5522e9109fc532acec84721c869aa787ada8d9e7f65aa7568694180432dc85238b5c5c77e423270ea23b23bdba599
7
+ data.tar.gz: 7809f2772864a1a5b3bc596dddc97cea43d04e56e8c0f2b9072813dad1fe05099808a97247d966b6e6c48d391fcb778158c7b09fdd1458776e2c67af5aec24ed
File without changes
@@ -1,7 +1,13 @@
1
+ require 'lumia-server/version'
2
+ require 'lumia-server/command/command'
3
+
1
4
  module LumiaServer
2
5
  module CLI
3
6
 
4
- autoload :Run, 'lumia-server/command/run'
7
+ autoload :Exec, 'lumia-server/command/exec'
8
+ autoload :Start, 'lumia-server/command/start'
9
+ autoload :Build, 'lumia-server/command/build'
10
+ autoload :Clean, 'lumia-server/command/clean'
5
11
 
6
12
  extend self
7
13
 
@@ -14,10 +20,15 @@ module LumiaServer
14
20
  def command(arg)
15
21
  name = arg.to_s.downcase
16
22
  unless (name = constants.detect { |c| c.to_s.downcase == name })
17
- $stderr.puts "Unknown command provided: #{arg}"
23
+ puts "Unknown command provided: #{arg}"
18
24
  exit 1
19
25
  end
20
26
  const_get(name)
21
27
  end
28
+
29
+ def error(message)
30
+ puts "Error: #{message}"
31
+ exit 1
32
+ end
22
33
  end
23
34
  end
@@ -0,0 +1,58 @@
1
+ require 'lumia-server/server'
2
+
3
+ module LumiaServer
4
+ module CLI
5
+ class Build < Command
6
+
7
+ require 'erb'
8
+ require 'yaml'
9
+
10
+ def run
11
+ FileUtils.mkdir_p File.join(Dir.home, '.lumia')
12
+
13
+ LumiaServer::CLI.error('server.json was not found') unless File.exist?('server.json')
14
+ @data = JSON.parse(File.read('server.json'))
15
+
16
+ time = Benchmark.realtime {
17
+ puts 'Initialising server..'
18
+ yaml_file = File.join('build', '.lumia', 'server.yml')
19
+ yaml = File.exist?(yaml_file) ? YAML.load(File.open(yaml_file)) : nil
20
+
21
+ @server = Server.new(@data, yaml)
22
+
23
+ puts 'Copying files..'
24
+ Dir.glob("src/**/*").each do |file|
25
+ unless File.directory?(file)
26
+ out = file.sub('src', 'build')
27
+ out = File.join(File.dirname(out), File.basename(out, '.erb'))
28
+ FileUtils.mkdir_p File.dirname(out)
29
+ File.open(file) do |fh|
30
+ erb = ERB.new(fh.read)
31
+ File.open(out, 'w') do |f|
32
+ f.write erb.result(binding)
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ puts 'Copying secrets..'
39
+ @server.build_secrets
40
+
41
+ @server.install_platform
42
+ @server.install_mods
43
+
44
+ update_yaml = {}
45
+ update_yaml[@server.platform.name] = @server.platform.id
46
+ @server.mods.each { |m|
47
+ unless m.provider.nil?
48
+ update_yaml[m.name] = m.id
49
+ end
50
+ }
51
+ FileUtils.mkdir_p File.dirname(yaml_file)
52
+ File.open(yaml_file, 'w') { |f| f.write update_yaml.to_yaml }
53
+ }
54
+ puts "Done. Server has been installed (#{time.round(3)}s)."
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,10 @@
1
+ module LumiaServer
2
+ module CLI
3
+ class Clean < Command
4
+
5
+ def run
6
+ FileUtils.rm_rf('build')
7
+ end
8
+ end
9
+ end
10
+ end
@@ -4,18 +4,18 @@ module LumiaServer
4
4
  module CLI
5
5
  class Command
6
6
 
7
+ require 'fileutils'
7
8
  require 'json'
9
+ require 'benchmark'
10
+
11
+ attr_reader :args
12
+ attr_reader :options
8
13
 
9
14
  def initialize(args, options)
10
15
  @args = args
11
16
  @options = options
12
17
  end
13
18
 
14
- def error(message)
15
- $stderr.puts message
16
- exit 1
17
- end
18
-
19
19
  def run; end
20
20
  end
21
21
  end
@@ -0,0 +1,26 @@
1
+ module LumiaServer
2
+ module CLI
3
+ class Exec < Command
4
+
5
+ def run
6
+ LumiaServer::CLI.error('No script name provided') unless @args[0]
7
+
8
+ file = File.join(Dir.pwd, 'scripts', @args[0])
9
+ server = File.join(Dir.pwd, 'server.json')
10
+
11
+ Dir.chdir('build') do
12
+ if File.exist?(file)
13
+ exec "bash #{file}"
14
+ else
15
+ LumiaServer::CLI.error('No script name provided') unless @args[0]
16
+ LumiaServer::CLI.error('server.json was not found') unless File.exist?(server)
17
+ @data = JSON.parse(File.read(server))
18
+ line = @data['scripts'][@args[0]]
19
+ LumiaServer::CLI.error("Invalid script name: #{@args[0]}") unless line
20
+ exec line
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ module LumiaServer
2
+ module CLI
3
+ class Start < Command
4
+
5
+ def run
6
+ Exec.new(['start'], @options).run
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,52 @@
1
+ module LumiaServer
2
+ class Platform
3
+
4
+ require 'open-uri'
5
+
6
+ attr_reader :data
7
+ attr_reader :server_yaml
8
+
9
+ attr_reader :name
10
+ attr_reader :version
11
+ attr_reader :provider
12
+ attr_reader :id
13
+
14
+ autoload :Custom, 'lumia-server/platform/custom'
15
+ autoload :Paper, 'lumia-server/platform/paper'
16
+ autoload :BungeeCord, 'lumia-server/platform/bungeecord'
17
+ autoload :Waterfall, 'lumia-server/platform/waterfall'
18
+
19
+ def self.new(data, server_yaml)
20
+ return super if self < Platform
21
+ const = data['id'].to_s.downcase
22
+ raise format('Unknown platform %p', data['id']) unless (const = constants.detect { |c| c.to_s.downcase == const })
23
+ platform = const_get(const).new(data, server_yaml)
24
+ platform
25
+ end
26
+
27
+ def initialize(data, server_yaml)
28
+ @data = data
29
+ @server_yaml = server_yaml
30
+
31
+ @version = data['version']
32
+ @provider = data.key?('provider') ? Provider.new(@data['provider']) : nil
33
+ @id = provider.nil? ? version : provider.id
34
+ end
35
+
36
+ def install
37
+ if needs_update
38
+ puts "#{name}: updating.."
39
+ install_platform
40
+ else
41
+ puts "#{name}: up-to-date"
42
+ end
43
+ end
44
+
45
+ def needs_update
46
+ server_yaml.nil? || server_yaml[name] != id
47
+ end
48
+
49
+ def install_platform;
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,22 @@
1
+ module LumiaServer
2
+ class Platform
3
+ class BungeeCord < Platform
4
+
5
+ URL = 'https://ci.md-5.net/job/BungeeCord/lastStableBuild/artifact/bootstrap/target/BungeeCord.jar'
6
+
7
+ def initialize(data, server_yaml)
8
+ super
9
+ @name = 'BungeeCord'
10
+ end
11
+
12
+ def install_platform
13
+ file = 'BungeeCord.jar'
14
+ if provider.nil?
15
+ IO.copy_stream(open(URL), File.join('build', file))
16
+ else
17
+ provider.install('build', file)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ module LumiaServer
2
+ class Platform
3
+ class Custom < Platform
4
+
5
+ def build
6
+ super
7
+ file = File.join(@data.key?('file') ? @data['file'] : 'server.jar')
8
+ IO.copy_stream(open(@data['url']), file)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ module LumiaServer
2
+ class Platform
3
+ class Paper < Platform
4
+
5
+ VERSIONS = {
6
+ '1.12.2' => 'https://ci.destroystokyo.com/job/PaperSpigot/1294/artifact/paperclip.jar',
7
+ '1.11.2' => 'https://ci.destroystokyo.com/job/PaperSpigot/1104/artifact/paperclip.jar',
8
+ '1.10.2' => 'https://ci.destroystokyo.com/job/PaperSpigot/916/artifact/paperclip.jar',
9
+ '1.9.4' => 'https://ci.destroystokyo.com/job/PaperSpigot/773/artifact/paperclip.jar',
10
+ '1.8.8' => 'https://ci.destroystokyo.com/job/PaperSpigot/443/artifact/paperclip.jar'
11
+ }.freeze
12
+
13
+ def initialize(data, server_yaml)
14
+ super
15
+ @name = 'Paper'
16
+ end
17
+
18
+ def install_platform
19
+ if provider.nil?
20
+ if VERSIONS.key?(version)
21
+ file = 'paperclip.jar'
22
+ IO.copy_stream(open(VERSIONS[version]), File.join('build', file))
23
+ else
24
+ raise 'Invalid platform version provided'
25
+ end
26
+ else
27
+ provider.install('build')
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ module LumiaServer
2
+ class Platform
3
+ class Waterfall < Platform
4
+
5
+ URL = 'https://ci.destroystokyo.com/job/Waterfall/lastStableBuild/artifact/Waterfall-Proxy/bootstrap/target/Waterfall.jar'
6
+
7
+ def initialize(data, server_yaml)
8
+ super
9
+ @name = 'Waterfall'
10
+ end
11
+
12
+ def install_platform
13
+ file = 'Waterfall.jar'
14
+ if provider.nil?
15
+ IO.copy_stream(open(URL), File.join('build', file))
16
+ else
17
+ provider.install('build', file)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,41 @@
1
+ module LumiaServer
2
+ class Plugin
3
+
4
+ attr_reader :data
5
+ attr_reader :server_yaml
6
+
7
+ attr_reader :name
8
+ attr_reader :version
9
+ attr_reader :provider
10
+ attr_reader :id
11
+
12
+ def initialize(data, server_yaml)
13
+ @data = data
14
+ @server_yaml = server_yaml
15
+
16
+ @name = data['name']
17
+ @version = data['version']
18
+ @provider = data.key?('provider') ? Provider.new(@data['provider']) : nil
19
+ @id = provider.nil? ? version : provider.id
20
+ end
21
+
22
+ def install
23
+ unless provider.nil?
24
+ if needs_update
25
+ puts "#{name}: updating.."
26
+ install_mod
27
+ else
28
+ puts "#{name}: up-to-date"
29
+ end
30
+ end
31
+ end
32
+
33
+ def needs_update
34
+ server_yaml.nil? || server_yaml[name] != id
35
+ end
36
+
37
+ def install_mod
38
+ provider.install(File.join('build', 'plugins'))
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ module LumiaServer
2
+ class Provider
3
+
4
+ require 'open-uri'
5
+
6
+ autoload :Direct, 'lumia-server/provider/direct'
7
+
8
+ attr_reader :data
9
+ attr_reader :id
10
+
11
+ def self.new(data)
12
+ return super if self < Provider
13
+ const = data['id'].to_s.downcase
14
+ raise format('Unknown platform %p', options[:platform]) unless (const = constants.detect { |c| c.to_s.downcase == const })
15
+ platform = const_get(const).new(data)
16
+ platform
17
+ end
18
+
19
+ def initialize(data)
20
+ @data = data
21
+ end
22
+
23
+ def install(dir, file = nil, force = true); end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module LumiaServer
2
+ class Provider
3
+ class Direct < Provider
4
+
5
+ def initialize(data)
6
+ super
7
+ @id = data['url']
8
+ end
9
+
10
+ def install(dir, file = nil, force = true)
11
+ name = data['file'].nil? ? file : data['file']
12
+ LumiaServer::CLI.error('No file name provided for provider \'direct\'') if name.nil?
13
+
14
+ file = dir.nil? ? name : File.join(dir, name)
15
+ if !File.exist?(file) || force
16
+ IO.copy_stream(open(data['url']), file)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ module LumiaServer
2
+ class Secret
3
+
4
+ attr_reader :data
5
+ attr_reader :source
6
+ attr_reader :destination
7
+
8
+ def initialize(home, data)
9
+ @data = data
10
+ @source = File.join(home, data['source'])
11
+ @destination = File.join('build', data['destination'])
12
+ end
13
+
14
+ def build
15
+ # Quick Fix
16
+ if File.extname(destination).empty?
17
+ FileUtils.mkdir_p destination
18
+ end
19
+
20
+ Dir.glob(source).each do |file|
21
+ FileUtils.cp_r(file, destination)
22
+ puts "Copied #{file} to #{File.absolute_path(destination)}"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,70 @@
1
+ require 'lumia-server/plugin'
2
+ require 'lumia-server/platform'
3
+ require 'lumia-server/provider'
4
+ require 'lumia-server/secret'
5
+
6
+ module LumiaServer
7
+ class Server
8
+
9
+ require 'fileutils'
10
+
11
+ attr_reader :platform
12
+ attr_reader :mods
13
+ attr_reader :secrets
14
+
15
+ def initialize(data, server_yaml)
16
+ @platform = Platform.new(data['platform'], server_yaml)
17
+ @mods = []
18
+ if data.key?('mods')
19
+ data['mods'].each do |mod|
20
+ @mods << Plugin.new(mod, server_yaml)
21
+ end
22
+ end
23
+ @secrets = []
24
+ if data.key?('secrets')
25
+ data['secrets'].each do |secret|
26
+ @secrets << Secret.new(File.join(Dir.home, '.lumia'), secret)
27
+ end
28
+ end
29
+ end
30
+
31
+ def info
32
+ puts " "
33
+ puts "Server Information:"
34
+ puts "-------------------"
35
+ puts "Platform: #{print(platform.name, 'Unknown')} (#{print(platform.version, '0.0.0')})"
36
+ puts "Plugins (#{mods.length}):"
37
+ mods.each do |mod|
38
+ puts " - #{print(mod.name, 'Unknown')} (#{print(mod.version, '0.0.0')})"
39
+ end
40
+ puts "Secrets (#{secrets.length}):"
41
+ secrets.each do |secret|
42
+ puts " - #{secret.source}"
43
+ end
44
+ puts " "
45
+ end
46
+
47
+ def install_platform
48
+ FileUtils.mkdir_p 'build/plugins'
49
+ platform.install
50
+ end
51
+
52
+ def install_mods
53
+ mods.each do |mod|
54
+ mod.install
55
+ end
56
+ end
57
+
58
+ def build_secrets
59
+ secrets.each do |secret|
60
+ secret.build
61
+ end
62
+ end
63
+
64
+ private
65
+
66
+ def print(field, other)
67
+ field.nil? ? other : field
68
+ end
69
+ end
70
+ end
@@ -1,3 +1,3 @@
1
- module LumiaServer
2
- VERSION = "1.0.0.alpha".freeze
3
- end
1
+ module LumiaServer
2
+ VERSION = "1.0".freeze
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lumia-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conreptio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-08 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -48,8 +48,21 @@ files:
48
48
  - bin/lumia-server
49
49
  - lib/lumia-server.rb
50
50
  - lib/lumia-server/cli.rb
51
+ - lib/lumia-server/command/build.rb
52
+ - lib/lumia-server/command/clean.rb
51
53
  - lib/lumia-server/command/command.rb
52
- - lib/lumia-server/command/run.rb
54
+ - lib/lumia-server/command/exec.rb
55
+ - lib/lumia-server/command/start.rb
56
+ - lib/lumia-server/platform.rb
57
+ - lib/lumia-server/platform/bungeecord.rb
58
+ - lib/lumia-server/platform/custom.rb
59
+ - lib/lumia-server/platform/paper.rb
60
+ - lib/lumia-server/platform/waterfall.rb
61
+ - lib/lumia-server/plugin.rb
62
+ - lib/lumia-server/provider.rb
63
+ - lib/lumia-server/provider/direct.rb
64
+ - lib/lumia-server/secret.rb
65
+ - lib/lumia-server/server.rb
53
66
  - lib/lumia-server/version.rb
54
67
  homepage: https://github.com/neolumia/lumia-server
55
68
  licenses:
@@ -71,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
84
  version: 1.8.11
72
85
  requirements: []
73
86
  rubyforge_project:
74
- rubygems_version: 2.7.2
87
+ rubygems_version: 2.7.5
75
88
  signing_key:
76
89
  specification_version: 4
77
90
  summary: Minecraft Server Helper
@@ -1,24 +0,0 @@
1
- require 'lumia-server/command/command'
2
-
3
- module LumiaServer
4
- module CLI
5
- class Run < Command
6
-
7
- def run
8
- error('No script name provided') unless @args[0]
9
-
10
- file = File.join('scripts', @args[0])
11
- if File.exist?(file)
12
- exec "bash #{file}"
13
- else
14
- error('No script name provided') unless @args[0]
15
- error('server.json was not found') unless File.exist?('server.json')
16
- @data = JSON.parse(File.read('server.json'))
17
- line = @data['scripts'][@args[0]]
18
- error("Invalid script name: #{@args[0]}") unless line
19
- exec line
20
- end
21
- end
22
- end
23
- end
24
- end