appril-cli 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/boilerplate/app/core/boot.rb +46 -0
- data/boilerplate/app/core/generate_configs.rb +15 -60
- data/lib/appril-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cc0893ea5aa28fab9b811a299e262eee2073286
|
4
|
+
data.tar.gz: b77fb25b57f6b1f882553096c58e656129d2a81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6256202daa1c36fa70139d19732fb964aa8a98f89ee9c1c8ff23fb8bf1726bc389f66d961999041a4525a71bafcb810378faef649dca7ef063d1fa4c9e5d8b5c
|
7
|
+
data.tar.gz: 5e438a3c42920d405d7ab2d8c672e151bf36e11a3c394ce2e3186592b7b82684382727ee27740d96811e2f2637fcb25e12ed44522e18e252ed582094eb639303
|
@@ -1,6 +1,52 @@
|
|
1
1
|
# do NOT edit this file, edit base/boot.rb instead
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
+
require 'appril'
|
5
|
+
|
6
|
+
module Appril
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def load_config dir, env = RocketIO.environment
|
10
|
+
|
11
|
+
config = load_config_file("#{dir}/config.yml")
|
12
|
+
config.update(load_config_file("#{dir}/env/#{env}.yml"))
|
13
|
+
config[:environment] = env.to_s.freeze
|
14
|
+
|
15
|
+
Dir["#{dir}/**/*.yml"].each do |file|
|
16
|
+
next if File.dirname(file) == './env'
|
17
|
+
|
18
|
+
key = File.basename(file, '.yml')
|
19
|
+
next if key == 'config' || key == 'appril'
|
20
|
+
|
21
|
+
key_config = load_config_file(file)
|
22
|
+
key_config_keys = key_config.keys.map(&:to_s)
|
23
|
+
|
24
|
+
config[key] = if key_config_keys.include?(env.to_s)
|
25
|
+
# current environment found, use it
|
26
|
+
key_config[env]
|
27
|
+
else
|
28
|
+
if RocketIO::ENVIRONMENTS.keys.find {|k| key_config_keys.include?(k)}
|
29
|
+
# there are some environment(s), but no current one so set current environment to nil
|
30
|
+
nil
|
31
|
+
else
|
32
|
+
# there are no environments, so this config is available on any environment
|
33
|
+
key_config
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def config.method_missing key
|
40
|
+
self[key]
|
41
|
+
end
|
42
|
+
|
43
|
+
config
|
44
|
+
end
|
45
|
+
|
46
|
+
def load_config_file file
|
47
|
+
RocketIO.indifferent_params(YAML.load(File.read(file)) || {})
|
48
|
+
end
|
49
|
+
end
|
4
50
|
|
5
51
|
Dir.chdir File.expand_path('../..', __FILE__) do
|
6
52
|
require './base/boot'
|
@@ -4,52 +4,27 @@
|
|
4
4
|
|
5
5
|
require File.expand_path('../load', __FILE__)
|
6
6
|
|
7
|
-
module
|
7
|
+
module Appril
|
8
8
|
extend self
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
config = load_config_file("#{dir}/config.yml")
|
13
|
-
config.update(load_config_file("#{dir}/env/#{env}.yml"))
|
14
|
-
config[:environment] = env.to_s.freeze
|
15
|
-
|
16
|
-
Dir["#{dir}/**/*.yml"].each do |file|
|
17
|
-
next if File.dirname(file) == './env'
|
18
|
-
|
19
|
-
key = File.basename(file, '.yml')
|
20
|
-
next if key == 'config' || key == 'appril'
|
21
|
-
|
22
|
-
key_config = load_config_file(file)
|
23
|
-
key_config_keys = key_config.keys.map(&:to_s)
|
24
|
-
|
25
|
-
config[key] = if key_config_keys.include?(env.to_s)
|
26
|
-
# current environment found, use it
|
27
|
-
key_config[env]
|
28
|
-
else
|
29
|
-
if RocketIO::ENVIRONMENTS.keys.find {|k| key_config_keys.include?(k)}
|
30
|
-
# there are some environment(s), but no current one so set current environment to nil
|
31
|
-
nil
|
32
|
-
else
|
33
|
-
# there are no environments, so this config is available on any environment
|
34
|
-
key_config
|
35
|
-
end
|
36
|
-
end
|
10
|
+
def generate_configs dir
|
11
|
+
config = load_config("#{dir}/config", :development)
|
37
12
|
|
38
|
-
|
13
|
+
controllers = controllers_map(dir)
|
14
|
+
webpack_entries = webpack_entries(dir, controllers)
|
39
15
|
|
40
|
-
|
41
|
-
|
16
|
+
File.open File.expand_path('config.json', dir), 'w' do |f|
|
17
|
+
f << JSON.pretty_generate({
|
18
|
+
controllers: controllers,
|
19
|
+
webpack: {
|
20
|
+
path: config[:client_path],
|
21
|
+
url: config[:client_url],
|
22
|
+
entries: webpack_entries
|
23
|
+
}
|
24
|
+
})
|
42
25
|
end
|
43
|
-
|
44
|
-
config
|
45
26
|
end
|
46
27
|
|
47
|
-
|
48
|
-
def load_config_file file
|
49
|
-
RocketIO.indifferent_params(YAML.load(File.read(file)) || {})
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
28
|
def controllers_map dir
|
54
29
|
path_to_api = File.expand_path('base/api', dir)
|
55
30
|
RocketIO.controllers.each_with_object([]) do |controller,o|
|
@@ -67,7 +42,6 @@ module ApprilTools
|
|
67
42
|
end
|
68
43
|
end
|
69
44
|
|
70
|
-
|
71
45
|
def webpack_entries dir, controllers
|
72
46
|
entries = controllers.each_with_object({}) do |controller,o|
|
73
47
|
|
@@ -89,25 +63,6 @@ module ApprilTools
|
|
89
63
|
entries
|
90
64
|
end
|
91
65
|
|
92
|
-
|
93
|
-
def generate_configs dir
|
94
|
-
config = load_config("#{dir}/config", :development)
|
95
|
-
|
96
|
-
controllers = controllers_map(dir)
|
97
|
-
webpack_entries = webpack_entries(dir, controllers)
|
98
|
-
|
99
|
-
File.open File.expand_path('config.json', dir), 'w' do |f|
|
100
|
-
f << JSON.pretty_generate({
|
101
|
-
controllers: controllers,
|
102
|
-
webpack: {
|
103
|
-
path: config[:client_path],
|
104
|
-
url: config[:client_url],
|
105
|
-
entries: webpack_entries
|
106
|
-
}
|
107
|
-
})
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
66
|
def url_pattern controller
|
112
67
|
controller.url *controller.instance_method(:get).parameters.each_with_object([]) {|param,o|
|
113
68
|
pattern = if param[0] == :rest
|
@@ -122,4 +77,4 @@ module ApprilTools
|
|
122
77
|
end
|
123
78
|
end
|
124
79
|
|
125
|
-
|
80
|
+
Appril.generate_configs(File.expand_path('../..', __FILE__))
|
data/lib/appril-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appril-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slee Woo
|
@@ -153,5 +153,5 @@ rubyforge_project:
|
|
153
153
|
rubygems_version: 2.5.1
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
|
-
summary: '["appril-cli-0.0.
|
156
|
+
summary: '["appril-cli-0.0.1", "Appril CLI"]'
|
157
157
|
test_files: []
|