isomorfeus 1.0.0.zeta25 → 2.0.0.rc1

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +26 -31
  4. data/bin/ismos +2 -2
  5. data/bin/isomorfeus +2 -3
  6. data/lib/isomorfeus/cli.rb +118 -31
  7. data/lib/isomorfeus/command.rb +29 -31
  8. data/lib/isomorfeus/console.rb +21 -21
  9. data/lib/isomorfeus/installer/bundle.rb +13 -0
  10. data/lib/isomorfeus/installer/dsl.rb +67 -0
  11. data/lib/isomorfeus/installer/gemfile.rb +39 -0
  12. data/lib/isomorfeus/installer/install_targets.rb +29 -0
  13. data/lib/isomorfeus/installer/new_project.rb +19 -56
  14. data/lib/isomorfeus/installer/options_mangler.rb +16 -16
  15. data/lib/isomorfeus/installer/rack_servers.rb +5 -11
  16. data/lib/isomorfeus/installer/target/web.rb +54 -0
  17. data/lib/isomorfeus/installer/templates/.gitignore.erb +25 -25
  18. data/lib/isomorfeus/installer/templates/Gemfile.erb +20 -36
  19. data/lib/isomorfeus/installer/templates/anonymous_policy.rb.erb +3 -3
  20. data/lib/isomorfeus/installer/templates/app_loader.rb.erb +8 -8
  21. data/lib/isomorfeus/installer/templates/config.ru.erb +23 -23
  22. data/lib/isomorfeus/installer/templates/hello_component.rb.erb +5 -5
  23. data/lib/isomorfeus/installer/templates/iodine.rb.erb +5 -0
  24. data/lib/isomorfeus/installer/templates/isomorfeus_loader.rb.erb +16 -16
  25. data/lib/isomorfeus/installer/templates/isomorfeus_web_worker_loader.rb.erb +2 -2
  26. data/lib/isomorfeus/installer/templates/{mail_components_loader.rb.erb → mail_loader.rb.erb} +18 -18
  27. data/lib/isomorfeus/installer/templates/mail_preview.mustache.erb +14 -0
  28. data/lib/isomorfeus/installer/templates/my_app.rb.erb +10 -10
  29. data/lib/isomorfeus/installer/templates/navigation_links.rb.erb +8 -8
  30. data/lib/isomorfeus/installer/templates/not_found_404_component.rb.erb +6 -6
  31. data/lib/isomorfeus/installer/templates/roda_app.rb.erb +71 -0
  32. data/lib/isomorfeus/installer/templates/spec_helper.rb.erb +19 -22
  33. data/lib/isomorfeus/installer/templates/web.mustache.erb +15 -0
  34. data/lib/isomorfeus/installer/templates/{test_spec.rb.erb → web_spec.rb.erb} +12 -12
  35. data/lib/isomorfeus/installer/templates/welcome_component.rb.erb +5 -5
  36. data/lib/isomorfeus/installer/test_app_files.rb +24 -0
  37. data/lib/isomorfeus/installer/upgrade.rb +11 -0
  38. data/lib/isomorfeus/installer.rb +57 -261
  39. data/lib/isomorfeus/version.rb +3 -3
  40. data/lib/isomorfeus.rb +10 -8
  41. metadata +68 -63
  42. data/bin/yandle +0 -9
  43. data/lib/isomorfeus/installer/databases/arangodb.rb +0 -13
  44. data/lib/isomorfeus/installer/templates/Procfile.erb +0 -1
  45. data/lib/isomorfeus/installer/templates/ProcfileDebug.erb +0 -3
  46. data/lib/isomorfeus/installer/templates/ProcfileDev.erb +0 -3
  47. data/lib/isomorfeus/installer/templates/app.rb.erb +0 -57
  48. data/lib/isomorfeus/installer/templates/application.css.erb +0 -0
  49. data/lib/isomorfeus/installer/templates/application.js.erb +0 -25
  50. data/lib/isomorfeus/installer/templates/application_common.js.erb +0 -17
  51. data/lib/isomorfeus/installer/templates/application_ssr.js.erb +0 -23
  52. data/lib/isomorfeus/installer/templates/application_web_worker.js.erb +0 -6
  53. data/lib/isomorfeus/installer/templates/arango_config.rb.erb +0 -20
  54. data/lib/isomorfeus/installer/templates/debug.js.erb +0 -131
  55. data/lib/isomorfeus/installer/templates/development.js.erb +0 -110
  56. data/lib/isomorfeus/installer/templates/development_ssr.js.erb +0 -115
  57. data/lib/isomorfeus/installer/templates/iodine_config.rb.erb +0 -14
  58. data/lib/isomorfeus/installer/templates/mail_components.js.erb +0 -23
  59. data/lib/isomorfeus/installer/templates/package.json.erb +0 -43
  60. data/lib/isomorfeus/installer/templates/production.js.erb +0 -100
@@ -1,261 +1,57 @@
1
- module Isomorfeus
2
- module Installer
3
- # driver support
4
-
5
- def self.add_database(name, props)
6
- databases[name] = props
7
- end
8
-
9
- def self.add_rack_server(name, props)
10
- rack_servers[name] = props
11
- end
12
-
13
- class << self
14
- # application options
15
- attr_reader :app_class
16
- attr_reader :app_require
17
- attr_accessor :database
18
- attr_accessor :framework
19
- attr_accessor :isomorfeus_module
20
- attr_reader :project_dir
21
- attr_reader :project_name
22
- attr_accessor :rack_server
23
- attr_accessor :rack_server_name
24
- attr_accessor :source_dir
25
-
26
- # installer options
27
- attr_reader :options
28
- end
29
-
30
- def self.set_project_names(pro_dir)
31
- @project_dir = pro_dir
32
- @project_name = pro_dir.underscore
33
- @app_class = @project_name.camelize + 'App'
34
- @app_require = @project_name + '_app'
35
- end
36
-
37
- def self.options=(options)
38
- Isomorfeus::Installer::OptionsMangler.mangle_options(options)
39
- @options = options
40
- end
41
-
42
- def self.sorted_databases
43
- databases.keys.sort
44
- end
45
-
46
- def self.sorted_policies
47
- policies.keys.sort
48
- end
49
-
50
- def self.sorted_rack_servers
51
- rack_servers.keys.sort
52
- end
53
-
54
- def self.databases
55
- @databases ||= {}
56
- end
57
-
58
- def self.policies
59
- @policies ||= {}
60
- end
61
-
62
- def self.rack_servers
63
- @rack_servers ||= {}
64
- end
65
-
66
- # installer options and config
67
-
68
- def self.module_directories
69
- %w[databases]
70
- end
71
-
72
- # installer paths
73
-
74
- def self.base_path
75
- @base_path ||= File.realpath(File.join(File.dirname(File.realpath(__FILE__)), 'installer'))
76
- end
77
-
78
- def self.templates_path
79
- @templates_path ||= File.realpath(File.join(File.dirname(File.realpath(__FILE__)), 'installer', 'templates'))
80
- end
81
-
82
- # app paths
83
-
84
- def self.asset_output_path
85
- File.join('public', 'assets')
86
- end
87
-
88
- def self.entrypoint_path(entrypoint)
89
- File.join(isomorfeus_path, 'imports', entrypoint)
90
- end
91
-
92
- def self.isomorfeus_path
93
- 'app'
94
- end
95
-
96
- def self.webpack_config_path(config_file)
97
- File.join( 'webpack', config_file)
98
- end
99
-
100
- def self.stylesheet_path(stylesheet)
101
- File.join(isomorfeus_path, 'styles', stylesheet)
102
- end
103
-
104
- def self.middlewares_includes
105
- 'extend Isomorfeus::Transport::Middlewares'
106
- end
107
-
108
- # install helpers
109
-
110
- def self.generate_gem_line(gem_hash)
111
- line = "gem '#{gem_hash[:name]}', '#{gem_hash[:version]}'"
112
- line << ", require: false" if gem_hash.has_key?(:require) && !gem_hash[:require]
113
- line << "\n"
114
- end
115
-
116
- def self.create_directories
117
- # no created: handlers
118
- %w[channels components data imports locales mail_components operations policies server styles].each do |isomorfeus_dir|
119
- create_directory(File.join(isomorfeus_path, isomorfeus_dir))
120
- end
121
- create_directory('spec')
122
- end
123
-
124
- def self.create_directory(directory)
125
- unless Dir.exist?(directory)
126
- puts "Creating directory #{directory}."
127
- FileUtils.mkdir_p(directory)
128
- FileUtils.touch(File.join(directory, '.keep'))
129
- end
130
- end
131
-
132
- def self.create_file_from_template(template_path, target_file_path, data_hash)
133
- template = ERB.new(File.read(File.join(templates_path, template_path), mode: 'r'))
134
- result = template.result_with_hash(data_hash)
135
- ext = File.exist?(target_file_path) ? '_new' : ''
136
- File.write(target_file_path + ext, result, mode: 'w')
137
- end
138
-
139
- def self.install_framework
140
- data_hash = { app_class: app_class,
141
- middlewares: create_middlewares,
142
- middlewares_includes: middlewares_includes,
143
- rack_server_init: rack_server[:rack_server_init] }
144
- create_file_from_template('app.rb.erb', "#{@project_name}_app.rb", data_hash)
145
- create_file_from_template( rack_server[:init_template], rack_server[:init_template][0..-5], {})
146
- data_hash = { app_require: app_require, app_class: app_class }
147
- create_file_from_template('config.ru.erb', 'config.ru', data_hash)
148
- create_file_from_template(File.join('app_loader.rb.erb'), 'app_loader.rb', {})
149
- create_file_from_template(File.join('arango_config.rb.erb'), 'arango_config.rb', data_hash )
150
- create_file_from_template(File.join('.gitignore.erb'), '.gitignore', {})
151
- end
152
-
153
- def self.install_isomorfeus_entries
154
- data_hash = { app_class: app_class }
155
- create_file_from_template('isomorfeus_loader.rb.erb', File.join(isomorfeus_path, 'isomorfeus_loader.rb'), data_hash)
156
- create_file_from_template('isomorfeus_web_worker_loader.rb.erb', File.join(isomorfeus_path, 'isomorfeus_web_worker_loader.rb'), data_hash)
157
- create_file_from_template('mail_components_loader.rb.erb', File.join(isomorfeus_path, 'mail_components_loader.rb'), data_hash)
158
- end
159
-
160
- def self.install_js_entries
161
- data_hash = {}
162
- create_file_from_template('application.js.erb', entrypoint_path('application.js'), data_hash)
163
- create_file_from_template('application_common.js.erb', entrypoint_path('application_common.js'), data_hash)
164
- create_file_from_template('application_ssr.js.erb', entrypoint_path('application_ssr.js'), data_hash)
165
- create_file_from_template('application_web_worker.js.erb', entrypoint_path('application_web_worker.js'), data_hash)
166
- create_file_from_template('mail_components.js.erb', entrypoint_path('mail_components.js'), data_hash)
167
- end
168
-
169
- def self.install_styles
170
- create_file_from_template('application.css.erb', stylesheet_path('application.css'), {})
171
- end
172
-
173
- def self.install_webpack_config
174
- File.unlink(webpack_config_path('production.js'), webpack_config_path('development.js'),
175
- webpack_config_path('debug.js'))
176
- create_file_from_template('production.js.erb', webpack_config_path('production.js'), {})
177
- create_file_from_template('development.js.erb', webpack_config_path('development.js'), {})
178
- create_file_from_template('development_ssr.js.erb', webpack_config_path('development_ssr.js'), {})
179
- create_file_from_template('debug.js.erb', webpack_config_path('debug.js'), {})
180
- end
181
-
182
- def self.create_gemfile
183
- rack_server_gems = ''
184
- Isomorfeus::Installer.rack_servers[options[:rack_server]]&.fetch(:gems)&.each do |gem|
185
- rack_server_gems << generate_gem_line(gem)
186
- end
187
- database_gems = ''
188
- Isomorfeus::Installer.databases[options[:database]]&.fetch(:gems)&.each do |gem|
189
- database_gems << generate_gem_line(gem)
190
- end
191
- data_hash = { database_gems: database_gems.chop,
192
- rack_server_gems: rack_server_gems.chop }
193
- if source_dir
194
- %i[isomorfeus isomorfeus_data isomorfeus_i18n isomorfeus_mailer isomorfeus_operation isomorfeus_policy isomorfeus_transport].each do |i_module|
195
- data_hash[i_module] = i_module == isomorfeus_module ? "path: '..'" : "path: '../../#{i_module.to_s.tr('_', '-')}'"
196
- end
197
- data_hash[:isomorfeus_version] = nil
198
- else
199
- data_hash[:isomorfeus_version] = "'~> #{Isomorfeus::VERSION}'"
200
- end
201
- create_file_from_template('Gemfile.erb', 'Gemfile', data_hash)
202
- end
203
-
204
- def self.create_components
205
- data_hash = { app_class: app_class }
206
- create_file_from_template('my_app.rb.erb',
207
- File.join(isomorfeus_path, 'components', app_class.underscore + '.rb'), data_hash)
208
- create_file_from_template('hello_component.rb.erb',
209
- File.join(isomorfeus_path, 'components', 'hello_component.rb'), {})
210
- create_file_from_template('navigation_links.rb.erb',
211
- File.join(isomorfeus_path, 'components', 'navigation_links.rb'), {})
212
- create_file_from_template('not_found_404_component.rb.erb',
213
- File.join(isomorfeus_path, 'components', 'not_found_404_component.rb'), {})
214
- create_file_from_template('welcome_component.rb.erb',
215
- File.join(isomorfeus_path, 'components', 'welcome_component.rb'), {})
216
- end
217
-
218
- def self.create_middlewares
219
- "use_isomorfeus_middlewares"
220
- end
221
-
222
- def self.create_package_json
223
- data_hash = { application_name: app_class }
224
- create_file_from_template('package.json.erb', 'package.json', data_hash)
225
- end
226
-
227
- def self.create_policy
228
- create_file_from_template('anonymous_policy.rb.erb',
229
- File.join(isomorfeus_path, 'policies', 'anonymous_policy.rb'), {})
230
- end
231
-
232
- def self.create_procfile
233
- data_hash = { rack_server_start_command: rack_server[:start_command] }
234
- create_file_from_template('Procfile.erb', 'Procfile', data_hash)
235
- create_file_from_template('ProcfileDev.erb', 'ProcfileDev', data_hash)
236
- create_file_from_template('ProcfileDebug.erb', 'ProcfileDebug', data_hash)
237
- end
238
-
239
- def self.create_spec
240
- data_hash = { app_class: app_class, app_require: app_require, rack_server: rack_server_name }
241
- create_file_from_template('spec_helper.rb.erb', File.join('spec', 'spec_helper.rb'), data_hash)
242
- create_file_from_template('test_spec.rb.erb', File.join('spec', 'test_spec.rb'), {})
243
- end
244
-
245
- def self.use_asset_bundler?
246
- options.has_key?('asset_bundler')
247
- end
248
-
249
- def self.copy_source_dir_files
250
- Dir.glob("#{source_dir}/**/*").each do |file|
251
- if File.file?(file)
252
- target_file = file[(source_dir.size+1)..-1]
253
- target_dir = File.dirname(target_file)
254
- Dir.mkdir(target_dir) unless Dir.exist?(target_dir)
255
- puts "Copying #{file} to #{target_file}."
256
- FileUtils.copy(file, target_file)
257
- end
258
- end
259
- end
260
- end
261
- end
1
+ module Isomorfeus
2
+ module Installer
3
+
4
+ class << self
5
+ # application options
6
+ attr_reader :app_class
7
+ attr_accessor :database
8
+ attr_accessor :framework
9
+ attr_accessor :isomorfeus_module
10
+ attr_reader :project_dir
11
+ attr_reader :project_name
12
+ attr_accessor :rack_server
13
+ attr_accessor :rack_server_name
14
+ attr_reader :roda_app_class
15
+ attr_reader :roda_app_path
16
+ attr_accessor :source_dir
17
+
18
+ # installer options
19
+ attr_reader :options
20
+
21
+ def set_project_names(pro_dir)
22
+ @project_dir = pro_dir
23
+ @project_name = pro_dir.underscore
24
+ @app_class = @project_name.camelize + 'App'
25
+ @roda_app_class = @project_name.camelize + 'RodaApp'
26
+ @roda_app_path = @project_name + '_roda_app'
27
+ end
28
+
29
+ def options=(options)
30
+ Isomorfeus::Installer::OptionsMangler.mangle_options(options)
31
+ @options = options
32
+ end
33
+
34
+ def add_rack_server(name, props)
35
+ rack_servers[name] = props
36
+ end
37
+
38
+ def rack_servers
39
+ @rack_servers ||= {}
40
+ end
41
+
42
+ def sorted_rack_servers
43
+ rack_servers.keys.sort
44
+ end
45
+
46
+ # installer paths
47
+
48
+ def base_path
49
+ @base_path ||= File.realpath(File.join(File.dirname(File.realpath(__FILE__)), 'installer'))
50
+ end
51
+
52
+ def templates_path
53
+ @templates_path ||= File.realpath(File.join(File.dirname(File.realpath(__FILE__)), 'installer', 'templates'))
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,3 +1,3 @@
1
- module Isomorfeus
2
- VERSION = '1.0.0.zeta25'
3
- end
1
+ module Isomorfeus
2
+ VERSION = '2.0.0.rc1'
3
+ end
data/lib/isomorfeus.rb CHANGED
@@ -1,8 +1,10 @@
1
- require 'isomorfeus-redux'
2
- require 'isomorfeus-react'
3
- require 'isomorfeus-policy'
4
- require 'isomorfeus-transport'
5
- require 'isomorfeus-i18n'
6
- require 'isomorfeus-data'
7
- require 'isomorfeus-operation'
8
- require 'isomorfeus-mailer'
1
+ require 'isomorfeus-speednode'
2
+ require 'isomorfeus-asset-manager'
3
+ require 'isomorfeus-redux'
4
+ require 'isomorfeus-preact'
5
+ require 'isomorfeus-policy'
6
+ require 'isomorfeus-transport'
7
+ require 'isomorfeus-i18n'
8
+ require 'isomorfeus-data'
9
+ require 'isomorfeus-operation'
10
+ require 'isomorfeus-mailer'