appril-cli 0.1.1 → 0.2.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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/app/base/assets/styles.css +2 -0
  3. data/{boilerplate/app/base/api → app/base/components}/base_controller.rb +3 -1
  4. data/app/base/components/deploy.js +25 -0
  5. data/app/base/components/index/index.js +3 -0
  6. data/app/base/components/index/server.rb +13 -0
  7. data/{boilerplate/app/base/api → app/base/components}/rtcp_controller.rb +5 -7
  8. data/app/base/core.js +77 -0
  9. data/app/base/templates/layout.liquid +13 -0
  10. data/app/config/config.rb +11 -0
  11. data/{sandbox → app}/config/config.yml +8 -4
  12. data/{boilerplate/app → app}/core/Gemfile +2 -2
  13. data/{sandbox → app}/core/boot.rb +2 -4
  14. data/app/core/generate_configs.rb +7 -0
  15. data/{boilerplate/app → app}/core/load.rb +2 -2
  16. data/{boilerplate/app/core/load_api.rb → app/core/load_components.rb} +2 -1
  17. data/app/generators/_component/index.js +3 -0
  18. data/app/generators/_component/template.html +3 -0
  19. data/app/generators/component +29 -0
  20. data/app/package.json +30 -0
  21. data/{boilerplate/app → app}/webpack/alias.js +3 -3
  22. data/app/webpack/entry.js +3 -0
  23. data/{boilerplate/app → app}/webpack/extensions.js +1 -2
  24. data/app/webpack/loaders.js +47 -0
  25. data/app/webpack/output.js +9 -0
  26. data/app/webpack/plugins.js +38 -0
  27. data/app/webpack.config.js +29 -0
  28. data/lib/appril-cli/assertions.rb +5 -21
  29. data/lib/appril-cli/docker/build.rb +35 -31
  30. data/lib/appril-cli/docker/install.rb +18 -11
  31. data/lib/appril-cli/docker/update.rb +20 -11
  32. data/lib/appril-cli/docker.rb +14 -43
  33. data/lib/appril-cli/helpers.rb +7 -9
  34. data/lib/appril-cli/install.rb +30 -0
  35. data/lib/appril-cli/update.rb +34 -0
  36. data/lib/appril-cli/version.rb +1 -1
  37. data/lib/appril-cli.rb +62 -47
  38. metadata +52 -109
  39. data/boilerplate/app/base/api/deploy.coffee +0 -45
  40. data/boilerplate/app/base/api/index/client.coffee +0 -4
  41. data/boilerplate/app/base/api/index/server.rb +0 -3
  42. data/boilerplate/app/base/core.coffee +0 -113
  43. data/boilerplate/app/base/helpers/application_helpers.coffee +0 -1
  44. data/boilerplate/app/base/templates/access_denied.html +0 -3
  45. data/boilerplate/app/base/templates/layout.liquid +0 -11
  46. data/boilerplate/app/base/templates/layouts/main.html +0 -1
  47. data/boilerplate/app/base/templates/layouts/none.html +0 -1
  48. data/boilerplate/app/config/config.rb +0 -14
  49. data/boilerplate/app/config/config.yml +0 -18
  50. data/boilerplate/app/core/boot.rb +0 -72
  51. data/boilerplate/app/core/generate_configs.rb +0 -79
  52. data/boilerplate/app/generators/api/client.coffee +0 -4
  53. data/boilerplate/app/generators/api/server.rb +0 -3
  54. data/boilerplate/app/package.json +0 -10
  55. data/boilerplate/app/webpack/config.js +0 -6
  56. data/boilerplate/app/webpack/entry.js +0 -3
  57. data/boilerplate/app/webpack/loaders.js +0 -15
  58. data/boilerplate/app/webpack/output.js +0 -11
  59. data/boilerplate/app/webpack/plugins.js +0 -19
  60. data/boilerplate/app/webpack.config.js +0 -19
  61. data/boilerplate/crudle/Gemfile +0 -7
  62. data/boilerplate/crudle/base/api/deploy.coffee +0 -51
  63. data/boilerplate/crudle/base/api/index/client.coffee +0 -5
  64. data/boilerplate/crudle/base/api/index/layout.html +0 -5
  65. data/boilerplate/crudle/base/api/index/server.rb +0 -7
  66. data/boilerplate/crudle/base/templates/menu.html +0 -3
  67. data/boilerplate/crudle/generators/api/client.coffee +0 -17
  68. data/boilerplate/crudle/generators/api/editor/layout.html +0 -3
  69. data/boilerplate/crudle/generators/api/list/item.html +0 -3
  70. data/boilerplate/crudle/generators/api/server.rb +0 -26
  71. data/boilerplate/crudle/package.json +0 -13
  72. data/boilerplate/crudle/webpack/loaders.js +0 -16
  73. data/lib/appril-cli/app/install.rb +0 -47
  74. data/lib/appril-cli/app/update.rb +0 -28
  75. data/lib/appril-cli/app.rb +0 -46
  76. data/lib/appril-cli/generator/api.rb +0 -16
  77. data/lib/appril-cli/generator.rb +0 -32
  78. data/sandbox/.gitignore +0 -6
  79. data/sandbox/.pryrc +0 -1
  80. data/sandbox/Gemfile +0 -7
  81. data/sandbox/Rakefile +0 -1
  82. data/sandbox/base/api/base_controller.rb +0 -21
  83. data/sandbox/base/api/index/client.coffee +0 -4
  84. data/sandbox/base/api/index/layout.html +0 -3
  85. data/sandbox/base/api/index/server.rb +0 -3
  86. data/sandbox/base/api/rtcp_controller.rb +0 -22
  87. data/sandbox/base/assets/styles.css +0 -0
  88. data/sandbox/base/boot.rb +0 -2
  89. data/sandbox/base/core.coffee +0 -128
  90. data/sandbox/base/helpers/application_helpers.coffee +0 -1
  91. data/sandbox/base/helpers/application_helpers.rb +0 -4
  92. data/sandbox/base/load.rb +0 -0
  93. data/sandbox/base/models/base_model.rb +0 -0
  94. data/sandbox/base/templates/access_denied.html +0 -3
  95. data/sandbox/base/templates/layout.liquid +0 -11
  96. data/sandbox/base/templates/layouts/main.html +0 -1
  97. data/sandbox/base/templates/layouts/none.html +0 -1
  98. data/sandbox/base/templates/menu.html +0 -3
  99. data/sandbox/config/config.rb +0 -9
  100. data/sandbox/config/env/development.yml +0 -0
  101. data/sandbox/config/env/production.yml +0 -0
  102. data/sandbox/config/env/stage.yml +0 -0
  103. data/sandbox/config/env/test.yml +0 -0
  104. data/sandbox/config.ru +0 -3
  105. data/sandbox/core/Gemfile +0 -4
  106. data/sandbox/core/generate_configs.rb +0 -125
  107. data/sandbox/core/load.rb +0 -14
  108. data/sandbox/core/load_controllers.rb +0 -14
  109. data/sandbox/generators/api/client.coffee +0 -11
  110. data/sandbox/generators/api/editor.html +0 -0
  111. data/sandbox/generators/api/layout.html +0 -0
  112. data/sandbox/generators/api/server.rb +0 -26
  113. data/sandbox/package.json +0 -15
  114. data/sandbox/webpack.config.js +0 -54
  115. /data/{boilerplate/app → app}/.gitignore +0 -0
  116. /data/{boilerplate/app → app}/.pryrc +0 -0
  117. /data/{boilerplate/app → app}/Gemfile +0 -0
  118. /data/{boilerplate/app → app}/Rakefile +0 -0
  119. /data/{boilerplate/app → app}/base/boot.rb +0 -0
  120. /data/{boilerplate/app/base/api/index/layout.html → app/base/components/index/template.html} +0 -0
  121. /data/{boilerplate/app → app}/base/helpers/application_helpers.rb +0 -0
  122. /data/{boilerplate/app/base/assets/styles.css → app/base/helpers/index.js} +0 -0
  123. /data/{boilerplate/app → app}/base/load.rb +0 -0
  124. /data/{boilerplate/app → app}/base/models/base_model.rb +0 -0
  125. /data/{boilerplate/app/public → app/compiled}/.ignore +0 -0
  126. /data/{boilerplate/app → app}/config/env/development.yml +0 -0
  127. /data/{boilerplate/app → app}/config/env/production.yml +0 -0
  128. /data/{boilerplate/app → app}/config/env/stage.yml +0 -0
  129. /data/{boilerplate/app → app}/config/env/test.yml +0 -0
  130. /data/{boilerplate/app → app}/config.ru +0 -0
  131. /data/{boilerplate/app → app}/core/load_helpers.rb +0 -0
  132. /data/{boilerplate/app → app}/core/load_models.rb +0 -0
  133. /data/{boilerplate/app/tmp → app/public}/.ignore +0 -0
  134. /data/{boilerplate/app/var → app/tmp}/.ignore +0 -0
  135. /data/{boilerplate/app/generators/api/layout.html → app/var/.ignore} +0 -0
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.1.1
4
+ version: 0.2.0
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-05-30 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Appril CLI
14
14
  email:
@@ -20,70 +20,55 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - ".gitignore"
22
22
  - Rakefile
23
+ - app/.gitignore
24
+ - app/.pryrc
25
+ - app/Gemfile
26
+ - app/Rakefile
27
+ - app/base/assets/styles.css
28
+ - app/base/boot.rb
29
+ - app/base/components/base_controller.rb
30
+ - app/base/components/deploy.js
31
+ - app/base/components/index/index.js
32
+ - app/base/components/index/server.rb
33
+ - app/base/components/index/template.html
34
+ - app/base/components/rtcp_controller.rb
35
+ - app/base/core.js
36
+ - app/base/helpers/application_helpers.rb
37
+ - app/base/helpers/index.js
38
+ - app/base/load.rb
39
+ - app/base/models/base_model.rb
40
+ - app/base/templates/layout.liquid
41
+ - app/compiled/.ignore
42
+ - app/config.ru
43
+ - app/config/config.rb
44
+ - app/config/config.yml
45
+ - app/config/env/development.yml
46
+ - app/config/env/production.yml
47
+ - app/config/env/stage.yml
48
+ - app/config/env/test.yml
49
+ - app/core/Gemfile
50
+ - app/core/boot.rb
51
+ - app/core/generate_configs.rb
52
+ - app/core/load.rb
53
+ - app/core/load_components.rb
54
+ - app/core/load_helpers.rb
55
+ - app/core/load_models.rb
56
+ - app/generators/_component/index.js
57
+ - app/generators/_component/template.html
58
+ - app/generators/component
59
+ - app/package.json
60
+ - app/public/.ignore
61
+ - app/tmp/.ignore
62
+ - app/var/.ignore
63
+ - app/webpack.config.js
64
+ - app/webpack/alias.js
65
+ - app/webpack/entry.js
66
+ - app/webpack/extensions.js
67
+ - app/webpack/loaders.js
68
+ - app/webpack/output.js
69
+ - app/webpack/plugins.js
23
70
  - appril-cli.gemspec
24
71
  - bin/appril
25
- - boilerplate/app/.gitignore
26
- - boilerplate/app/.pryrc
27
- - boilerplate/app/Gemfile
28
- - boilerplate/app/Rakefile
29
- - boilerplate/app/base/api/base_controller.rb
30
- - boilerplate/app/base/api/deploy.coffee
31
- - boilerplate/app/base/api/index/client.coffee
32
- - boilerplate/app/base/api/index/layout.html
33
- - boilerplate/app/base/api/index/server.rb
34
- - boilerplate/app/base/api/rtcp_controller.rb
35
- - boilerplate/app/base/assets/styles.css
36
- - boilerplate/app/base/boot.rb
37
- - boilerplate/app/base/core.coffee
38
- - boilerplate/app/base/helpers/application_helpers.coffee
39
- - boilerplate/app/base/helpers/application_helpers.rb
40
- - boilerplate/app/base/load.rb
41
- - boilerplate/app/base/models/base_model.rb
42
- - boilerplate/app/base/templates/access_denied.html
43
- - boilerplate/app/base/templates/layout.liquid
44
- - boilerplate/app/base/templates/layouts/main.html
45
- - boilerplate/app/base/templates/layouts/none.html
46
- - boilerplate/app/config.ru
47
- - boilerplate/app/config/config.rb
48
- - boilerplate/app/config/config.yml
49
- - boilerplate/app/config/env/development.yml
50
- - boilerplate/app/config/env/production.yml
51
- - boilerplate/app/config/env/stage.yml
52
- - boilerplate/app/config/env/test.yml
53
- - boilerplate/app/core/Gemfile
54
- - boilerplate/app/core/boot.rb
55
- - boilerplate/app/core/generate_configs.rb
56
- - boilerplate/app/core/load.rb
57
- - boilerplate/app/core/load_api.rb
58
- - boilerplate/app/core/load_helpers.rb
59
- - boilerplate/app/core/load_models.rb
60
- - boilerplate/app/generators/api/client.coffee
61
- - boilerplate/app/generators/api/layout.html
62
- - boilerplate/app/generators/api/server.rb
63
- - boilerplate/app/package.json
64
- - boilerplate/app/public/.ignore
65
- - boilerplate/app/tmp/.ignore
66
- - boilerplate/app/var/.ignore
67
- - boilerplate/app/webpack.config.js
68
- - boilerplate/app/webpack/alias.js
69
- - boilerplate/app/webpack/config.js
70
- - boilerplate/app/webpack/entry.js
71
- - boilerplate/app/webpack/extensions.js
72
- - boilerplate/app/webpack/loaders.js
73
- - boilerplate/app/webpack/output.js
74
- - boilerplate/app/webpack/plugins.js
75
- - boilerplate/crudle/Gemfile
76
- - boilerplate/crudle/base/api/deploy.coffee
77
- - boilerplate/crudle/base/api/index/client.coffee
78
- - boilerplate/crudle/base/api/index/layout.html
79
- - boilerplate/crudle/base/api/index/server.rb
80
- - boilerplate/crudle/base/templates/menu.html
81
- - boilerplate/crudle/generators/api/client.coffee
82
- - boilerplate/crudle/generators/api/editor/layout.html
83
- - boilerplate/crudle/generators/api/list/item.html
84
- - boilerplate/crudle/generators/api/server.rb
85
- - boilerplate/crudle/package.json
86
- - boilerplate/crudle/webpack/loaders.js
87
72
  - docker/Dockerfile
88
73
  - docker/run
89
74
  - docker/skel/build.sh
@@ -93,57 +78,15 @@ files:
93
78
  - docker/skel/start.sh
94
79
  - docker/start
95
80
  - lib/appril-cli.rb
96
- - lib/appril-cli/app.rb
97
- - lib/appril-cli/app/install.rb
98
- - lib/appril-cli/app/update.rb
99
81
  - lib/appril-cli/assertions.rb
100
82
  - lib/appril-cli/docker.rb
101
83
  - lib/appril-cli/docker/build.rb
102
84
  - lib/appril-cli/docker/install.rb
103
85
  - lib/appril-cli/docker/update.rb
104
- - lib/appril-cli/generator.rb
105
- - lib/appril-cli/generator/api.rb
106
86
  - lib/appril-cli/helpers.rb
87
+ - lib/appril-cli/install.rb
88
+ - lib/appril-cli/update.rb
107
89
  - lib/appril-cli/version.rb
108
- - sandbox/.gitignore
109
- - sandbox/.pryrc
110
- - sandbox/Gemfile
111
- - sandbox/Rakefile
112
- - sandbox/base/api/base_controller.rb
113
- - sandbox/base/api/index/client.coffee
114
- - sandbox/base/api/index/layout.html
115
- - sandbox/base/api/index/server.rb
116
- - sandbox/base/api/rtcp_controller.rb
117
- - sandbox/base/assets/styles.css
118
- - sandbox/base/boot.rb
119
- - sandbox/base/core.coffee
120
- - sandbox/base/helpers/application_helpers.coffee
121
- - sandbox/base/helpers/application_helpers.rb
122
- - sandbox/base/load.rb
123
- - sandbox/base/models/base_model.rb
124
- - sandbox/base/templates/access_denied.html
125
- - sandbox/base/templates/layout.liquid
126
- - sandbox/base/templates/layouts/main.html
127
- - sandbox/base/templates/layouts/none.html
128
- - sandbox/base/templates/menu.html
129
- - sandbox/config.ru
130
- - sandbox/config/config.rb
131
- - sandbox/config/config.yml
132
- - sandbox/config/env/development.yml
133
- - sandbox/config/env/production.yml
134
- - sandbox/config/env/stage.yml
135
- - sandbox/config/env/test.yml
136
- - sandbox/core/Gemfile
137
- - sandbox/core/boot.rb
138
- - sandbox/core/generate_configs.rb
139
- - sandbox/core/load.rb
140
- - sandbox/core/load_controllers.rb
141
- - sandbox/generators/api/client.coffee
142
- - sandbox/generators/api/editor.html
143
- - sandbox/generators/api/layout.html
144
- - sandbox/generators/api/server.rb
145
- - sandbox/package.json
146
- - sandbox/webpack.config.js
147
90
  homepage: https://github.com/appril/appril-cli
148
91
  licenses:
149
92
  - MIT
@@ -167,5 +110,5 @@ rubyforge_project:
167
110
  rubygems_version: 2.5.1
168
111
  signing_key:
169
112
  specification_version: 4
170
- summary: '["appril-cli-0.1.1", "Appril CLI"]'
113
+ summary: '["appril-cli-0.2.0", "Appril CLI"]'
171
114
  test_files: []
@@ -1,45 +0,0 @@
1
- _ = {
2
- has: require('lodash/has')
3
- isFunction: require('lodash/isFunction')
4
- }
5
-
6
- templates = {
7
- none: require('templates/layouts/none')
8
- main: require('templates/layouts/main')
9
- }
10
-
11
- previous_layout = null
12
- module.exports = (api, env) ->
13
-
14
- layout = if _.has(api, 'layout')
15
-
16
- api_layout = if _.isFunction(api.layout)
17
- api.layout(env)
18
- else
19
- api.layout
20
- #end
21
-
22
- if api_layout == false
23
- 'none'
24
- else
25
- api_layout || 'main'
26
- #end
27
-
28
- else
29
- 'main'
30
- #end
31
-
32
- if layout == previous_layout
33
- # do not re-render body if current api uses same layout as previous one
34
- return api(env)
35
- #end
36
- previous_layout = layout
37
-
38
- env.render
39
- el: 'body'
40
- template: templates[layout] || templates.none
41
- oncomplete: ->
42
- api(env)
43
- #end
44
- #end
45
- #end
@@ -1,4 +0,0 @@
1
-
2
- module.exports = (env) ->
3
- env.render
4
- template: require('./layout')
@@ -1,3 +0,0 @@
1
- class Index < BaseController
2
- map Cfg.server_url
3
- end
@@ -1,113 +0,0 @@
1
- _ =
2
- merge: require('lodash/merge')
3
- isFunction: require('lodash/isFunction')
4
- #end
5
-
6
- Core = require('appril')
7
- Page = require('appril-page')
8
- Load = require('appril-load')
9
- Render = require('appril-ractive')
10
- Reporter = require('appril-reporter')
11
- DeployApi = require('api/deploy.coffee')
12
- require 'appril-polyfills'
13
- require 'assets/styles.css'
14
-
15
- CONSIDER_IDLE_AFTER = 5 * 60
16
-
17
- window.Cfg = {}
18
- window.Util = {}
19
- window.App = {}
20
- # window.Alert = require('appril-alert')
21
-
22
- for k, v of require('appril-util')
23
- Util[k] = v
24
- #end
25
-
26
- # for k, v of require('appril-datetime')
27
- # Util[k] = v
28
- # #end
29
-
30
- for k, v of require('helpers/application_helpers.coffee')
31
- Util[k] = v
32
- #end
33
-
34
- Object.freeze(Util)
35
-
36
- Render.default_el = -> '#content'
37
- Render.global_data = -> {App: App, Cfg: Cfg, Util: Util}
38
- Render.global_handlers = -> {}
39
-
40
-
41
- for name, controller of Core.controllers
42
- App[name] = controller
43
- #end
44
-
45
-
46
- Core.on_initialize = (msg) ->
47
- if window.Cfg = msg.data.cfg
48
- delete msg.data.cfg
49
- Object.freeze(Cfg)
50
- #end
51
-
52
- for k, v of msg.data
53
- App[k] = v
54
- #end
55
-
56
- Reporter CONSIDER_IDLE_AFTER, (status) ->
57
- # close connection if user went away
58
- Core.disconnect() if status == 'away'
59
- #end
60
- #end
61
-
62
-
63
- previous_api = null
64
- Core.on_controller_matched = (controller, context) ->
65
-
66
- controller.load (api) ->
67
- context.save()
68
-
69
- env = {
70
- render: Render
71
- render_component: Render.component
72
- render_string: Render.string
73
- page: new Page
74
- controller: controller
75
- api: controller.ws
76
- }
77
- _.merge(env, env.page)
78
-
79
- if previous_api?.teardown
80
- previous_api.teardown(env)
81
- #end
82
- previous_api = api
83
-
84
- if api.has_css && !controller.css_loaded
85
- Load.stylesheet controller.client_url + '.css', ->
86
- controller.css_loaded = true
87
- #end
88
-
89
- if _.isFunction(api.acl)
90
-
91
- if api.acl(env)
92
- DeployApi(api, env)
93
- else
94
- Render
95
- el: 'body'
96
- template: require('templates/layouts/main')
97
- partials: partials
98
- oncomplete: ->
99
- Render(template: require('templates/access_denied'))
100
- #end
101
-
102
- else
103
- DeployApi(api, env)
104
- #end
105
-
106
- #end
107
- #end
108
-
109
-
110
- document.addEventListener 'DOMContentLoaded', ->
111
- # make sure this matches the RTCPController URL
112
- Core.connect('__rtcp__')
113
- #end
@@ -1 +0,0 @@
1
- # this file will be loaded before other files found in helpers/ folder
@@ -1,3 +0,0 @@
1
- <h4>
2
- Please authorize to view this page
3
- </h4>
@@ -1,11 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
6
- <script type="text/javascript">window.module = {}</script>
7
- <script src="{{client_url}}/core.js"></script>
8
- <link rel="stylesheet" href="{{client_url}}/core.css">
9
- </head>
10
- <body></body>
11
- </html>
@@ -1 +0,0 @@
1
- <div id="content"></div>
@@ -1 +0,0 @@
1
- <div id="content"></div>
@@ -1,14 +0,0 @@
1
-
2
- # loading .yml configs from current directory.
3
- # config.yml will be loaded first.
4
- Cfg = Appril.load_config(File.expand_path('..', __FILE__))
5
-
6
- # it is highly recommended to freeze configs so they stay unaltered on runtime.
7
- Cfg.freeze
8
-
9
- # loading any .rb files in current dir.
10
- # this one will be skipped automatically.
11
- %w[
12
- ../*.rb
13
- ../**/*.rb
14
- ].each {|p| Dir[File.expand_path(p, __FILE__)].each {|f| require(f)} }
@@ -1,18 +0,0 @@
1
-
2
- # configs here will be the same on all environments.
3
- # if some configs differs on some environment,
4
- # put them into appropriate env/[ENVIRONMENT].yml file
5
-
6
- # multiple .yml files allowed in config folder.
7
- # for example config/db.yml file will be loaded into Cfg.db in server app.
8
- # arbitrary .yml files can have environment related configs.
9
-
10
-
11
- # base URL for server app
12
- server_url: /
13
-
14
- # base URL for compiled client app
15
- client_url: /public_app
16
-
17
- # where webpack should install compiled app. relative to webpack.config.js
18
- client_path: ./
@@ -1,72 +0,0 @@
1
- # do NOT edit this file, edit base/boot.rb instead
2
-
3
- require 'yaml'
4
- require 'appril'
5
-
6
- module Appril
7
- extend self
8
-
9
- def load_config *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_config_file("#{dir}/config.yml"))
15
- config.update(load_config_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_config_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 no current one 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_config_file file
60
- RocketIO.indifferent_params(YAML.load(File.read(file)) || {})
61
- end
62
- end
63
-
64
- Dir.chdir File.expand_path('../..', __FILE__) do
65
- require './base/boot'
66
-
67
- require 'bundler/setup'
68
- Bundler.require(:default)
69
- Bundler.require(RocketIO.environment)
70
-
71
- require './config/config'
72
- end
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # do NOT edit this file
4
-
5
- require File.expand_path('../load', __FILE__)
6
-
7
- module Appril
8
- extend self
9
-
10
- def generate_configs dir
11
- config = load_config("#{dir}/config", env: :development)
12
-
13
- api = controllers_map(dir)
14
- webpack_entries = webpack_entries(dir, api)
15
-
16
- File.open(File.expand_path('api.json', dir), 'w') {|f| f << JSON.pretty_generate(api)}
17
-
18
- File.open File.expand_path('webpack/config.json', dir), 'w' do |f|
19
- f << JSON.pretty_generate({
20
- path: config[:client_path],
21
- url: config[:client_url],
22
- entries: webpack_entries
23
- })
24
- end
25
- end
26
-
27
- def controllers_map dir
28
- path_to_api = File.expand_path('base/api', dir)
29
- RocketIO.controllers.each_with_object([]) do |controller,o|
30
- next unless controller.superclass == ::BaseController
31
-
32
- o << {
33
- path: controller.dirname.sub(path_to_api, '').gsub(/\A\/|\/\Z/, ''),
34
- url: controller.url,
35
- url_pattern: url_pattern(controller),
36
- name: controller.name.gsub('::', '__'),
37
- api: controller.api.keys
38
- }
39
- end.sort do |a,b|
40
- b[:url].split('/').size <=> a[:url].split('/').size
41
- end
42
- end
43
-
44
- def webpack_entries dir, controllers
45
- entries = controllers.each_with_object({}) do |controller,o|
46
-
47
- next unless entry = %w[
48
- ./base/api/%s/client.js
49
- ./base/api/%s/client.coffee
50
- ].map {|p| p % controller[:path]}.find {|f| File.file?(File.expand_path(f, dir))}
51
-
52
- o[controller[:path]] = File.join('./base/api', controller[:path], File.basename(entry))
53
- end
54
-
55
- if core = %w[
56
- ./base/core.js
57
- ./base/core.coffee
58
- ].find {|f| File.file?(File.expand_path(f, dir))}
59
- entries[:core] = core
60
- end
61
-
62
- entries
63
- end
64
-
65
- def url_pattern controller
66
- controller.url *controller.instance_method(:index).parameters.each_with_object([]) {|param,o|
67
- pattern = if param[0] == :rest
68
- "*"
69
- elsif param[0] == :req
70
- ":#{param[1]}"
71
- elsif param[0] == :opt
72
- ":#{param[1]}?"
73
- end
74
- o << pattern if pattern
75
- }
76
- end
77
- end
78
-
79
- Appril.generate_configs(File.expand_path('../..', __FILE__))
@@ -1,4 +0,0 @@
1
-
2
- module.exports = (env) ->
3
- env.render
4
- template: require('./layout')
@@ -1,3 +0,0 @@
1
- class CONTROLLER_NAME < BaseController
2
-
3
- end
@@ -1,10 +0,0 @@
1
- {
2
- "name": "MyApp",
3
- "version": "0.0.0",
4
- "description": "...",
5
- "dependencies": {
6
- "appril": "*",
7
- "appril-ractive": "*",
8
- "extract-text-webpack-plugin": "1"
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- var fs = require('fs'),
2
- path = require('path'),
3
- config_file = path.resolve(__dirname, 'config.json')
4
- ;
5
-
6
- module.exports = JSON.parse(fs.readFileSync(config_file))
@@ -1,3 +0,0 @@
1
- var config = require('./config.js');
2
-
3
- module.exports = config.entries
@@ -1,15 +0,0 @@
1
- var ExtractTextPlugin = require("extract-text-webpack-plugin");
2
-
3
- module.exports = [
4
- { test: /\.coffee$/, loader: 'coffee-loader' },
5
- { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") },
6
- { test: /\.json$/, loader: 'json-loader' },
7
- { test: /\.otf($|\?)/, loader: require.resolve('file-loader') },
8
- { test: /\.ttf($|\?)/, loader: require.resolve('file-loader') },
9
- { test: /\.eot($|\?)/, loader: require.resolve('file-loader') },
10
- { test: /\.svg($|\?)/, loader: require.resolve('file-loader') },
11
- { test: /\.png($|\?)/, loader: require.resolve('url-loader') + '?limit=10000&mimetype=image/png' },
12
- { test: /\.jpg($|\?)/, loader: require.resolve('file-loader') },
13
- { test: /\.gif($|\?)/, loader: require.resolve('file-loader') },
14
- { test: /\.woff[2]?($|\?)/, loader: require.resolve('url-loader') + '?limit=10000&mimetype=application/font-woff' },
15
- ]
@@ -1,11 +0,0 @@
1
- var path = require('path'),
2
- config = require('./config.js'),
3
- app_env = process.env.APP_ENV || 'development'
4
- ;
5
-
6
- module.exports = {
7
- path: path.join(config.path, config.url, app_env),
8
- filename: '[name].js',
9
- publicPath: path.join(config.url, app_env, '/'), // trailing slash required
10
- libraryTarget: 'commonjs2'
11
- }
@@ -1,19 +0,0 @@
1
- var webpack = require('webpack'),
2
- ExtractTextPlugin = require("extract-text-webpack-plugin")
3
- ;
4
-
5
- var plugins = [
6
- new webpack.optimize.CommonsChunkPlugin('core', 'core.js'),
7
- new ExtractTextPlugin("[name].css")
8
- ]
9
-
10
- if (process.env.APP_ENV == 'production') {
11
- plugins.push(new webpack.optimize.UglifyJsPlugin({
12
- compress: { warnings: false },
13
- screwIE8: true,
14
- sourceMap: false,
15
- mangle: true
16
- }))
17
- }
18
-
19
- module.exports = plugins