raindeer 0.7.0 → 0.8.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 +4 -4
- data/lib/cli/static/static.rb +62 -1
- data/lib/raindeer/cli.rb +2 -0
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e658170ed7da3124e736b68df8a271a9c6bfce0eae60d2b25e36196bec2e3c2
|
|
4
|
+
data.tar.gz: 22c8a59224ba2cdf3956c18b57261460334798015570e134c5da1bc7e5e85501
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 861bb11691f40b9436b73d24754c2a2c0391d6910318a59dde2ec5f809308cf6cdce7da132b31dd794db3c99c1708bdb84d299e5c0e4e91b4fb2a2217db3abda
|
|
7
|
+
data.tar.gz: 36b8b720352d4152e18e142ae66479b278848fc74f3cc1959441285d8f8612893ae9932bf2129336f23192582e68b26b46451962a527b5e4eddaf7375bd1a47a
|
data/lib/cli/static/static.rb
CHANGED
|
@@ -3,14 +3,75 @@
|
|
|
3
3
|
require 'antlers'
|
|
4
4
|
require 'lowload'
|
|
5
5
|
|
|
6
|
+
require 'async'
|
|
7
|
+
require 'async/http/internet'
|
|
8
|
+
require 'fileutils'
|
|
9
|
+
|
|
6
10
|
module Rain
|
|
7
11
|
module CLI
|
|
8
12
|
module Static
|
|
9
13
|
extend self
|
|
10
14
|
|
|
15
|
+
Result = Data.define(:path, :html)
|
|
16
|
+
|
|
11
17
|
def build(application_path:)
|
|
12
18
|
metadata = LowLoad.dirload(File.expand_path('app', application_path))
|
|
13
|
-
|
|
19
|
+
|
|
20
|
+
build_path = File.expand_path('build', application_path)
|
|
21
|
+
FileUtils.rm_rf(build_path)
|
|
22
|
+
FileUtils.mkdir_p(build_path)
|
|
23
|
+
FileUtils.cp_r(File.expand_path('public', application_path), File.expand_path('public', build_path))
|
|
24
|
+
|
|
25
|
+
request_paths(metadata:, application_path:).each do |result|
|
|
26
|
+
path = File.expand_path(result.path, build_path)
|
|
27
|
+
FileUtils.mkdir_p(path)
|
|
28
|
+
File.write(File.expand_path('index.html', path), result.html)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def request_paths(metadata:, application_path:)
|
|
35
|
+
tasks = metadata.url_paths.keys.compact.map do |file_path|
|
|
36
|
+
Async do
|
|
37
|
+
request_path = request_path(application_path:, file_path:)
|
|
38
|
+
request_url = endpoint + request_path
|
|
39
|
+
|
|
40
|
+
response = client.get(request_url)
|
|
41
|
+
response_html = response.read
|
|
42
|
+
response.close
|
|
43
|
+
|
|
44
|
+
Result.new(path: request_path, html: response_html)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
tasks.map(&:result)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def request_path(application_path:, file_path:)
|
|
52
|
+
file_path.delete_prefix("#{application_path}/app/pages/")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def client
|
|
56
|
+
Async::HTTP::Internet.new
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def endpoint
|
|
60
|
+
"http://#{config.host}:#{config.port}/"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def config
|
|
64
|
+
env = {
|
|
65
|
+
host: ENV.fetch('RAIN_HOST', nil),
|
|
66
|
+
port: ENV.fetch('RAIN_PORT', nil),
|
|
67
|
+
web_root: ENV.fetch('RAIN_WEB_ROOT', nil),
|
|
68
|
+
debug_mode: ConfigLoader.parse_boolean(ENV.fetch('RAIN_DEBUG', true)),
|
|
69
|
+
matrix_mode: ConfigLoader.parse_boolean(ENV.fetch('RAIN_MATRIX', nil)),
|
|
70
|
+
mirror_mode: ConfigLoader.parse_boolean(ENV.fetch('RAIN_MIRROR', nil)),
|
|
71
|
+
}
|
|
72
|
+
config_path = File.expand_path('config/config.yaml', Dir.pwd)
|
|
73
|
+
|
|
74
|
+
ConfigLoader.load(config_path, env)
|
|
14
75
|
end
|
|
15
76
|
end
|
|
16
77
|
end
|
data/lib/raindeer/cli.rb
CHANGED
data/lib/version.rb
CHANGED