appril-cli 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/Gemfile +1 -1
- data/app/base/app.js +8 -90
- data/app/base/bootstrap/api_callbacks.js +14 -0
- data/app/base/{component.js → bootstrap/component.js} +0 -1
- data/app/base/bootstrap/components.js +15 -0
- data/app/base/bootstrap/router.js +32 -0
- data/app/base/bootstrap/rtcp.js +14 -0
- data/app/base/bootstrap/store.js +27 -0
- data/app/base/bootstrap/vue_plugins.js +27 -0
- data/app/config/config.rb +2 -2
- data/app/core/boot.rb +1 -5
- data/app/core/generate_configs.rb +79 -2
- data/app/core/load_configs.rb +63 -0
- data/app/package.json +1 -1
- data/lib/appril-cli/version.rb +1 -1
- metadata +12 -5
- /data/app/base/store/{modules.js → components.js} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39c148a207991873f601d0278b707baa497b5db3
|
4
|
+
data.tar.gz: 5ac6342115df0ecf940e2f0b130cc8294fd7e6cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a03831c158147e7a45362d762c94842aeb6b8d076422fb2a8a73a35e4f78db9a2bf93746152ffb378588f8b5948d67ad02a3e474257bc4261bd86cc609697f61
|
7
|
+
data.tar.gz: 6eb8180050fe5c1ea1de2014822d06734ec5c5ef969b20ebdb5882291ebbaab2acd42a497b1c8d67be7c5ad39e6de7b6f7635a429b9e4539339b89da668d63eb
|
data/app/Gemfile
CHANGED
data/app/base/app.js
CHANGED
@@ -1,100 +1,18 @@
|
|
1
|
-
|
2
1
|
const DEVELOPMENT = APP_ENV === 'development'
|
3
2
|
|
4
|
-
import {merge, map, reduce, filter, cloneDeep} from 'lodash'
|
5
3
|
import Vue from 'vue'
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import
|
11
|
-
import {state, mutations} from 'appril/store'
|
12
|
-
import config from 'app/appril.json'
|
13
|
-
|
14
|
-
/** delete or comment this line if your components piped through Crudle
|
15
|
-
import {state as crudle_state, mutations as crudle_mutations} from 'crudle/store'
|
16
|
-
merge(state, crudle_state)
|
17
|
-
merge(mutations, crudle_mutations) /* */
|
18
|
-
|
19
|
-
Vue.use(VueRouter)
|
20
|
-
Vue.use(Vuex)
|
4
|
+
import components from './bootstrap/components'
|
5
|
+
import store from './bootstrap/store'
|
6
|
+
import router from './bootstrap/router'
|
7
|
+
import vue_plugins from './bootstrap/vue_plugins'
|
8
|
+
import './assets/app.css'
|
21
9
|
|
22
|
-
|
23
|
-
Vue.config.devtools = true
|
24
|
-
vuex_plugins.push(VuexLogger())
|
25
|
-
}
|
26
|
-
|
27
|
-
const store = new Vuex.Store({
|
28
|
-
state: cloneDeep(state),
|
29
|
-
mutations,
|
30
|
-
strict: DEVELOPMENT,
|
31
|
-
plugins: vuex_plugins
|
32
|
-
})
|
10
|
+
Vue.config.devtools = DEVELOPMENT
|
33
11
|
|
34
|
-
|
35
|
-
|
36
|
-
on_request(params) {},
|
37
|
-
|
38
|
-
// do whatever with data received from server just before entering success callback
|
39
|
-
on_response(response) {},
|
40
|
-
|
41
|
-
// to be used for requests that does not define a error handler
|
42
|
-
on_error(error) {
|
43
|
-
Alert.error(error)
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
// RealTime Communication Protocol
|
48
|
-
import RTCP from 'appril/rtcp'
|
49
|
-
const rtcp = new RTCP(api_callbacks)
|
50
|
-
|
51
|
-
rtcp.connect({
|
52
|
-
// make sure this URL is matching RTCPController URL
|
53
|
-
path: config.server_url + '__rtcp__',
|
54
|
-
// disconnect if user is idle for N seconds (it will reconnect on user activity)
|
55
|
-
disconnect_after: 60
|
56
|
-
})
|
57
|
-
|
58
|
-
import {urlify} from 'appril-utils'
|
59
|
-
import api_builder from 'appril/api'
|
60
|
-
|
61
|
-
const components = reduce(config.components, function(map,component) {
|
62
|
-
component.url = urlify(component.url)
|
63
|
-
component.xhr = api_builder.xhr(component, api_callbacks)
|
64
|
-
component.rtcp = api_builder.rtcp(component, rtcp)
|
65
|
-
Object.defineProperty(component, 'api', {get() {return component[config.default_api]}})
|
66
|
-
map[component.name] = component
|
67
|
-
return map
|
68
|
-
}, {})
|
69
|
-
|
70
|
-
import deploy_component from './component'
|
71
|
-
|
72
|
-
const router = new VueRouter({
|
73
|
-
mode: 'history',
|
74
|
-
base: __dirname,
|
75
|
-
routes: map(filter(components, 'entry_path'), function(component) {
|
76
|
-
return {
|
77
|
-
name: component.name,
|
78
|
-
path: component.url_pattern,
|
79
|
-
component: (resolve) => System.import(`components/${component.entry_path}/index.js`).then(function(constructor) {
|
80
|
-
if (component.api._env) {
|
81
|
-
component.api._env().get({
|
82
|
-
success(env) {
|
83
|
-
store.commit('__SET_ENV__', {component: component.name, env})
|
84
|
-
resolve(deploy_component(components, component, constructor.default))
|
85
|
-
}
|
86
|
-
})
|
87
|
-
} else {
|
88
|
-
resolve(deploy_component(components, component, constructor.default))
|
89
|
-
}
|
90
|
-
})
|
91
|
-
}
|
92
|
-
})
|
93
|
-
})
|
12
|
+
for (let plugin of vue_plugins)
|
13
|
+
Vue.use(plugin)
|
94
14
|
|
95
15
|
document.addEventListener('DOMContentLoaded', function() {
|
96
|
-
Vue.use(vue_plugin({components, rtcp}))
|
97
|
-
|
98
16
|
new Vue({
|
99
17
|
router,
|
100
18
|
store,
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import Alert from 'appril-alert'
|
2
|
+
|
3
|
+
// do whatever with params Object just before sending to server
|
4
|
+
export function on_request(params) {
|
5
|
+
}
|
6
|
+
|
7
|
+
// do whatever with data received from server just before entering success callback
|
8
|
+
export function on_response(response) {
|
9
|
+
}
|
10
|
+
|
11
|
+
// used on requests that does not define own error handler
|
12
|
+
export function on_error(error) {
|
13
|
+
Alert.error(error)
|
14
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import {reduce} from 'lodash'
|
2
|
+
import {urlify} from 'appril-utils'
|
3
|
+
import api_builder from 'appril/api'
|
4
|
+
import * as callbacks from './api_callbacks'
|
5
|
+
import rtcp from './rtcp'
|
6
|
+
import {components, default_api} from 'app/appril.json'
|
7
|
+
|
8
|
+
export default reduce(components, function(map,component) {
|
9
|
+
component.url = urlify(component.url)
|
10
|
+
component.xhr = api_builder.xhr(component, callbacks)
|
11
|
+
component.rtcp = api_builder.rtcp(component, rtcp)
|
12
|
+
Object.defineProperty(component, 'api', {get() {return component[default_api]}})
|
13
|
+
map[component.name] = component
|
14
|
+
return map
|
15
|
+
}, {})
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import {map, filter} from 'lodash'
|
2
|
+
import Vue from 'vue'
|
3
|
+
import VueRouter from 'vue-router'
|
4
|
+
|
5
|
+
import components from './components'
|
6
|
+
import store from './store'
|
7
|
+
import componentify from './component'
|
8
|
+
|
9
|
+
Vue.use(VueRouter)
|
10
|
+
|
11
|
+
export default new VueRouter({
|
12
|
+
mode: 'history',
|
13
|
+
base: __dirname,
|
14
|
+
routes: map(filter(components, 'entry_path'), function(component) {
|
15
|
+
return {
|
16
|
+
name: component.name,
|
17
|
+
path: component.url_pattern,
|
18
|
+
component: (resolve) => System.import(`components/${component.entry_path}/index.js`).then(function(constructor) {
|
19
|
+
if (component.api._env) {
|
20
|
+
component.api._env().get({
|
21
|
+
success(env) {
|
22
|
+
store.commit('__SET_ENV__', {component: component.name, env})
|
23
|
+
resolve(componentify(components, component, constructor.default))
|
24
|
+
}
|
25
|
+
})
|
26
|
+
} else {
|
27
|
+
resolve(componentify(components, component, constructor.default))
|
28
|
+
}
|
29
|
+
})
|
30
|
+
}
|
31
|
+
})
|
32
|
+
})
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import RTCP from 'appril/rtcp'
|
2
|
+
import * as callbacks from './api_callbacks'
|
3
|
+
import {server_url} from 'app/appril.json'
|
4
|
+
|
5
|
+
const rtcp = new RTCP(callbacks)
|
6
|
+
|
7
|
+
rtcp.connect({
|
8
|
+
// make sure this URL is matching RTCPController URL
|
9
|
+
path: server_url + '__rtcp__',
|
10
|
+
// disconnect if user is idle for N seconds (it will reconnect on user activity)
|
11
|
+
disconnect_after: 60
|
12
|
+
})
|
13
|
+
|
14
|
+
export default rtcp
|
@@ -0,0 +1,27 @@
|
|
1
|
+
const DEVELOPMENT = APP_ENV === 'development'
|
2
|
+
|
3
|
+
import {forEach, merge} from 'lodash'
|
4
|
+
import Vue from 'vue'
|
5
|
+
import Vuex from 'vuex'
|
6
|
+
import VuexLogger from 'vuex/logger'
|
7
|
+
|
8
|
+
import state from 'base/store/state'
|
9
|
+
import * as mutations from 'base/store/mutations'
|
10
|
+
|
11
|
+
forEach(require('base/store/components'), function(s,n) {
|
12
|
+
state[n] = s.state
|
13
|
+
merge(mutations, s.mutations)
|
14
|
+
})
|
15
|
+
|
16
|
+
/** delete or comment this line if your components piped through Crudle
|
17
|
+
import {state as crudle_state, mutations as crudle_mutations} from 'crudle/store'
|
18
|
+
merge(state, crudle_state)
|
19
|
+
merge(mutations, crudle_mutations) /* */
|
20
|
+
|
21
|
+
Vue.use(Vuex)
|
22
|
+
export default new Vuex.Store({
|
23
|
+
state,
|
24
|
+
mutations,
|
25
|
+
strict: DEVELOPMENT,
|
26
|
+
plugins: DEVELOPMENT ? [VuexLogger()] : []
|
27
|
+
})
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import components from './components'
|
2
|
+
import rtcp from './rtcp'
|
3
|
+
|
4
|
+
export default [
|
5
|
+
|
6
|
+
function(vue) {
|
7
|
+
|
8
|
+
vue.prototype.rtcp = rtcp
|
9
|
+
|
10
|
+
Object.defineProperty(vue.prototype, 'env', {
|
11
|
+
get() {return this.$store ? this.$store.state.__ENV__[this.$router.currentRoute.name] || {} : {}}
|
12
|
+
})
|
13
|
+
|
14
|
+
Object.defineProperty(vue.prototype, 'components', {
|
15
|
+
get() {return components}
|
16
|
+
})
|
17
|
+
|
18
|
+
Object.defineProperty(vue.prototype, 'component', {
|
19
|
+
get() {return components[this.$router.currentRoute.name]}
|
20
|
+
})
|
21
|
+
|
22
|
+
Object.defineProperty(vue.prototype, 'api', {
|
23
|
+
get() {return components[this.$router.currentRoute.name].api}
|
24
|
+
})
|
25
|
+
}
|
26
|
+
|
27
|
+
]
|
data/app/config/config.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# loading .yml configs from current directory (config.yml will be loaded first)
|
2
|
-
Cfg = Appril.
|
2
|
+
Cfg = Appril::Configs.load(File.expand_path('..', __FILE__))
|
3
3
|
|
4
4
|
# it is highly recommended to freeze configs so they stay unaltered on runtime
|
5
5
|
Cfg.freeze
|
6
6
|
|
7
|
-
# loading all .rb files in current dir (this one will be skipped
|
7
|
+
# loading all .rb files in current dir (this one will be skipped)
|
8
8
|
%w[
|
9
9
|
../*.rb
|
10
10
|
../**/*.rb
|
data/app/core/boot.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
# do NOT edit this file, edit base/boot.rb instead
|
2
2
|
|
3
|
-
require 'appril'
|
4
|
-
require 'appril/load_configs'
|
5
|
-
|
6
3
|
Dir.chdir File.expand_path('../..', __FILE__) do
|
4
|
+
require './core/load_configs'
|
7
5
|
require './base/boot'
|
8
|
-
|
9
6
|
require 'bundler/setup'
|
10
7
|
Bundler.require(:default)
|
11
8
|
Bundler.require(RocketIO.environment)
|
12
|
-
|
13
9
|
require './config/config'
|
14
10
|
end
|
@@ -2,6 +2,83 @@
|
|
2
2
|
|
3
3
|
# do NOT edit this file
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
module Appril
|
8
|
+
module Configs
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def generate dir
|
12
|
+
components = self.components(dir)
|
13
|
+
generate_config_file(dir, components)
|
14
|
+
generate_store_modules_file(dir, components)
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_config_file dir, components
|
18
|
+
config = Configs.load("#{dir}/config", env: :development)
|
19
|
+
File.open File.expand_path('appril.json', dir), 'w' do |f|
|
20
|
+
f << JSON.pretty_generate({
|
21
|
+
build_path: config[:build_path],
|
22
|
+
client_url: config[:client_url],
|
23
|
+
server_url: config[:server_url],
|
24
|
+
default_api: config[:default_api],
|
25
|
+
components: components
|
26
|
+
})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_store_modules_file dir, components
|
31
|
+
|
32
|
+
lines = components.each_with_object([
|
33
|
+
'// auto-generated file, do not edit',
|
34
|
+
]) do |c,o|
|
35
|
+
next unless c[:name] # skip anonymous controllers
|
36
|
+
pattern = "base/components/#{c[:entry_path]}/store.*"
|
37
|
+
next unless file = Dir[File.expand_path(pattern, dir)].find {|e| File.file?(e)}
|
38
|
+
path = file.sub(dir, 'app')
|
39
|
+
o << "
|
40
|
+
import #{c[:name]} from '#{path}'
|
41
|
+
export {#{c[:name]}}
|
42
|
+
"
|
43
|
+
end
|
44
|
+
|
45
|
+
file = File.expand_path('base/store/components.js', dir)
|
46
|
+
FileUtils.mkdir_p(File.dirname(file))
|
47
|
+
File.open(file, 'w') {|f| f << lines.join("\n")}
|
48
|
+
end
|
49
|
+
|
50
|
+
def components dir
|
51
|
+
components_root = File.expand_path('base/components', dir) + '/'
|
52
|
+
RocketIO.controllers.each_with_object([]) do |controller,o|
|
53
|
+
next if controller.to_s =~ /BaseController|RTCPController/
|
54
|
+
entry = Dir["#{controller.dirname}/index.*"].find {|e| File.file?(e)}
|
55
|
+
o << {
|
56
|
+
entry_path: entry && File.dirname(entry.sub(components_root, '')),
|
57
|
+
url: controller.url,
|
58
|
+
url_pattern: url_pattern(controller),
|
59
|
+
name: controller.name.gsub('::', '__'),
|
60
|
+
controller_name: controller.name,
|
61
|
+
api: controller.api.keys
|
62
|
+
}
|
63
|
+
end.sort do |a,b|
|
64
|
+
b[:url].split('/').size <=> a[:url].split('/').size
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def url_pattern controller
|
69
|
+
controller.url *controller.instance_method(:index).parameters.each_with_object([]) {|param,o|
|
70
|
+
pattern = if param[0] == :rest
|
71
|
+
"*"
|
72
|
+
elsif param[0] == :req
|
73
|
+
":#{param[1]}"
|
74
|
+
elsif param[0] == :opt
|
75
|
+
":#{param[1]}?"
|
76
|
+
end
|
77
|
+
o << pattern if pattern
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
6
83
|
require File.expand_path('../load', __FILE__)
|
7
|
-
Appril.
|
84
|
+
Appril::Configs.generate(File.expand_path('../..', __FILE__))
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# do NOT edit this file, edit base/boot.rb instead
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Appril
|
6
|
+
module Configs
|
7
|
+
extend self
|
8
|
+
|
9
|
+
def load *dirs, env: RocketIO.environment
|
10
|
+
|
11
|
+
config = RocketIO.indifferent_params({environment: env.to_s.freeze})
|
12
|
+
|
13
|
+
dirs.each do |dir|
|
14
|
+
config.update(load_file("#{dir}/config.yml"))
|
15
|
+
config.update(load_file("#{dir}/env/#{env}.yml"))
|
16
|
+
|
17
|
+
loaded = [
|
18
|
+
File.expand_path("config.yml", dir),
|
19
|
+
File.expand_path("env/#{env}.yml", dir)
|
20
|
+
]
|
21
|
+
|
22
|
+
%w[
|
23
|
+
*.yml
|
24
|
+
**/*.yml
|
25
|
+
].each do |pattern|
|
26
|
+
Dir[File.join(dir, pattern)].each do |file|
|
27
|
+
|
28
|
+
path = File.expand_path(file, dir)
|
29
|
+
next if loaded.include?(path)
|
30
|
+
loaded << path
|
31
|
+
|
32
|
+
key = File.basename(file, '.yml')
|
33
|
+
key_config = load_file(file)
|
34
|
+
key_config_keys = key_config.keys.map(&:to_s)
|
35
|
+
|
36
|
+
config[key] = if key_config_keys.include?(config[:environment])
|
37
|
+
# current environment found, use it
|
38
|
+
key_config[config[:environment]]
|
39
|
+
else
|
40
|
+
if RocketIO::ENVIRONMENTS.keys.find {|k| key_config_keys.include?(k)}
|
41
|
+
# there are some environment(s), but current one is missing, so set current environment to nil
|
42
|
+
nil
|
43
|
+
else
|
44
|
+
# there are no environments, so this config is available on any environment
|
45
|
+
key_config
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def config.method_missing key
|
53
|
+
self[key]
|
54
|
+
end
|
55
|
+
|
56
|
+
config
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_file file
|
60
|
+
RocketIO.indifferent_params(YAML.load(File.read(file)) || {})
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/app/package.json
CHANGED
data/lib/appril-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appril-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slee Woo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Appril CLI
|
14
14
|
email:
|
@@ -27,7 +27,13 @@ files:
|
|
27
27
|
- app/base/app.js
|
28
28
|
- app/base/assets/app.css
|
29
29
|
- app/base/boot.rb
|
30
|
-
- app/base/
|
30
|
+
- app/base/bootstrap/api_callbacks.js
|
31
|
+
- app/base/bootstrap/component.js
|
32
|
+
- app/base/bootstrap/components.js
|
33
|
+
- app/base/bootstrap/router.js
|
34
|
+
- app/base/bootstrap/rtcp.js
|
35
|
+
- app/base/bootstrap/store.js
|
36
|
+
- app/base/bootstrap/vue_plugins.js
|
31
37
|
- app/base/components/base_controller.rb
|
32
38
|
- app/base/components/index/index.js
|
33
39
|
- app/base/components/index/server.rb
|
@@ -38,7 +44,7 @@ files:
|
|
38
44
|
- app/base/helpers/user.rb
|
39
45
|
- app/base/load.rb
|
40
46
|
- app/base/models/base_model.rb
|
41
|
-
- app/base/store/
|
47
|
+
- app/base/store/components.js
|
42
48
|
- app/base/store/mutations.js
|
43
49
|
- app/base/store/state.js
|
44
50
|
- app/base/templates/layout.liquid
|
@@ -55,6 +61,7 @@ files:
|
|
55
61
|
- app/core/generate_configs.rb
|
56
62
|
- app/core/load.rb
|
57
63
|
- app/core/load_components.rb
|
64
|
+
- app/core/load_configs.rb
|
58
65
|
- app/core/load_helpers.rb
|
59
66
|
- app/core/load_models.rb
|
60
67
|
- app/generators/_component/index.js
|
@@ -114,5 +121,5 @@ rubyforge_project:
|
|
114
121
|
rubygems_version: 2.5.1
|
115
122
|
signing_key:
|
116
123
|
specification_version: 4
|
117
|
-
summary: '["appril-cli-0.2.
|
124
|
+
summary: '["appril-cli-0.2.8", "Appril CLI"]'
|
118
125
|
test_files: []
|
File without changes
|