isomorfeus 1.0.0.zeta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/bin/isomorfeus +33 -0
  4. data/bin/yandle +9 -0
  5. data/lib/isomorfeus/cli.rb +33 -0
  6. data/lib/isomorfeus/console.rb +21 -0
  7. data/lib/isomorfeus/installer/databases/arangodb.rb +13 -0
  8. data/lib/isomorfeus/installer/new_project.rb +56 -0
  9. data/lib/isomorfeus/installer/options_mangler.rb +16 -0
  10. data/lib/isomorfeus/installer/rack_servers.rb +11 -0
  11. data/lib/isomorfeus/installer/templates/.gitignore.erb +25 -0
  12. data/lib/isomorfeus/installer/templates/.gitkeep.erb +0 -0
  13. data/lib/isomorfeus/installer/templates/Gemfile.erb +28 -0
  14. data/lib/isomorfeus/installer/templates/Procfile.erb +3 -0
  15. data/lib/isomorfeus/installer/templates/ProcfileDebug.erb +3 -0
  16. data/lib/isomorfeus/installer/templates/anonymous_policy.rb.erb +4 -0
  17. data/lib/isomorfeus/installer/templates/app.rb.erb +57 -0
  18. data/lib/isomorfeus/installer/templates/app_loader.rb.erb +8 -0
  19. data/lib/isomorfeus/installer/templates/application.css.erb +0 -0
  20. data/lib/isomorfeus/installer/templates/application.js.erb +25 -0
  21. data/lib/isomorfeus/installer/templates/application_common.js.erb +13 -0
  22. data/lib/isomorfeus/installer/templates/application_ssr.js.erb +23 -0
  23. data/lib/isomorfeus/installer/templates/application_web_worker.js.erb +6 -0
  24. data/lib/isomorfeus/installer/templates/arango_config.rb.erb +19 -0
  25. data/lib/isomorfeus/installer/templates/config.ru.erb +23 -0
  26. data/lib/isomorfeus/installer/templates/debug.js.erb +131 -0
  27. data/lib/isomorfeus/installer/templates/development.js.erb +110 -0
  28. data/lib/isomorfeus/installer/templates/development_ssr.js.erb +111 -0
  29. data/lib/isomorfeus/installer/templates/hello_component.rb.erb +6 -0
  30. data/lib/isomorfeus/installer/templates/iodine_config.rb.erb +14 -0
  31. data/lib/isomorfeus/installer/templates/isomorfeus_loader.rb.erb +16 -0
  32. data/lib/isomorfeus/installer/templates/isomorfeus_web_worker_loader.rb.erb +2 -0
  33. data/lib/isomorfeus/installer/templates/my_app.rb.erb +11 -0
  34. data/lib/isomorfeus/installer/templates/navigation_links.rb.erb +9 -0
  35. data/lib/isomorfeus/installer/templates/not_found_404_component.rb.erb +7 -0
  36. data/lib/isomorfeus/installer/templates/package.json.erb +42 -0
  37. data/lib/isomorfeus/installer/templates/production.js.erb +91 -0
  38. data/lib/isomorfeus/installer/templates/spec_helper.rb.erb +22 -0
  39. data/lib/isomorfeus/installer/templates/test_spec.rb.erb +13 -0
  40. data/lib/isomorfeus/installer/templates/welcome_component.rb.erb +6 -0
  41. data/lib/isomorfeus/installer.rb +257 -0
  42. data/lib/isomorfeus/version.rb +3 -0
  43. metadata +211 -0
@@ -0,0 +1,257 @@
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
+ 'isomorfeus'
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 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
+ end
158
+
159
+ def self.install_js_entries
160
+ data_hash = {}
161
+ create_file_from_template('application.js.erb', entrypoint_path('application.js'), data_hash)
162
+ create_file_from_template('application_common.js.erb', entrypoint_path('application_common.js'), data_hash)
163
+ create_file_from_template('application_ssr.js.erb', entrypoint_path('application_ssr.js'), data_hash)
164
+ create_file_from_template('application_web_worker.js.erb', entrypoint_path('application_web_worker.js'), data_hash)
165
+ end
166
+
167
+ def self.install_styles
168
+ create_file_from_template('application.css.erb', stylesheet_path('application.css'), {})
169
+ end
170
+
171
+ def self.install_webpack_config
172
+ File.unlink(webpack_config_path('production.js'), webpack_config_path('development.js'),
173
+ webpack_config_path('debug.js'))
174
+ create_file_from_template('production.js.erb', webpack_config_path('production.js'), {})
175
+ create_file_from_template('development.js.erb', webpack_config_path('development.js'), {})
176
+ create_file_from_template('development_ssr.js.erb', webpack_config_path('development_ssr.js'), {})
177
+ create_file_from_template('debug.js.erb', webpack_config_path('debug.js'), {})
178
+ end
179
+
180
+ def self.create_gemfile
181
+ rack_server_gems = ''
182
+ Isomorfeus::Installer.rack_servers[options[:rack_server]]&.fetch(:gems)&.each do |gem|
183
+ rack_server_gems << generate_gem_line(gem)
184
+ end
185
+ database_gems = ''
186
+ Isomorfeus::Installer.databases[options[:database]]&.fetch(:gems)&.each do |gem|
187
+ database_gems << generate_gem_line(gem)
188
+ end
189
+ data_hash = { database_gems: database_gems.chop,
190
+ rack_server_gems: rack_server_gems.chop }
191
+ %i[isomorfeus_data isomorfeus_i18n isomorfeus_operation isomorfeus_policy isomorfeus_transport].each do |i_module|
192
+ if source_dir
193
+ data_hash[i_module] = i_module == isomorfeus_module ? "path: '..'" : "path: '../../#{i_module.to_s.tr('_', '-')}'"
194
+ else
195
+ data_hash[i_module] = "'~> #{Isomorfeus::VERSION}'"
196
+ end
197
+ end
198
+ create_file_from_template('Gemfile.erb', 'Gemfile', data_hash)
199
+ end
200
+
201
+ def self.create_components
202
+ data_hash = { app_class: app_class }
203
+ create_file_from_template('my_app.rb.erb',
204
+ File.join(isomorfeus_path, 'components', app_class.underscore + '.rb'), data_hash)
205
+ create_file_from_template('hello_component.rb.erb',
206
+ File.join(isomorfeus_path, 'components', 'hello_component.rb'), {})
207
+ create_file_from_template('navigation_links.rb.erb',
208
+ File.join(isomorfeus_path, 'components', 'navigation_links.rb'), {})
209
+ create_file_from_template('not_found_404_component.rb.erb',
210
+ File.join(isomorfeus_path, 'components', 'not_found_404_component.rb'), {})
211
+ create_file_from_template('welcome_component.rb.erb',
212
+ File.join(isomorfeus_path, 'components', 'welcome_component.rb'), {})
213
+ end
214
+
215
+ def self.create_middlewares
216
+ "use_isomorfeus_middlewares"
217
+ end
218
+
219
+ def self.create_package_json
220
+ data_hash = { application_name: app_class }
221
+ create_file_from_template('package.json.erb', 'package.json', data_hash)
222
+ end
223
+
224
+ def self.create_policy
225
+ create_file_from_template('anonymous_policy.rb.erb',
226
+ File.join(isomorfeus_path, 'policies', 'anonymous_policy.rb'), {})
227
+ end
228
+
229
+ def self.create_procfile
230
+ data_hash = { rack_server_start_command: rack_server[:start_command] }
231
+ create_file_from_template('Procfile.erb', 'Procfile', data_hash)
232
+ create_file_from_template('ProcfileDebug.erb', 'ProcfileDebug', data_hash)
233
+ end
234
+
235
+ def self.create_spec
236
+ data_hash = { app_class: app_class, app_require: app_require, rack_server: rack_server_name }
237
+ create_file_from_template('spec_helper.rb.erb', File.join('spec', 'spec_helper.rb'), data_hash)
238
+ create_file_from_template('test_spec.rb.erb', File.join('spec', 'test_spec.rb'), {})
239
+ end
240
+
241
+ def self.use_asset_bundler?
242
+ options.has_key?('asset_bundler')
243
+ end
244
+
245
+ def self.copy_source_dir_files
246
+ Dir.glob("#{source_dir}/**/*").each do |file|
247
+ if File.file?(file)
248
+ target_file = file[(source_dir.size+1)..-1]
249
+ target_dir = File.dirname(target_file)
250
+ Dir.mkdir(target_dir) unless Dir.exist?(target_dir)
251
+ puts "Copying #{file} to #{target_file}."
252
+ FileUtils.copy(file, target_file)
253
+ end
254
+ end
255
+ end
256
+ end
257
+ end
@@ -0,0 +1,3 @@
1
+ module Isomorfeus
2
+ VERSION = '1.0.0.zeta6'
3
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isomorfeus
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.zeta6
5
+ platform: ruby
6
+ authors:
7
+ - Jan Biedermann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: oj
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.10.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.10.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.12.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.12.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: opal-webpack-loader
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.9
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.9
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.19.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.19.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.8.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 3.8.0
139
+ description: Create new isomorfeus-framework applications with ease.
140
+ email: jan@kursator.de
141
+ executables:
142
+ - isomorfeus
143
+ - yandle
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - LICENSE
148
+ - bin/isomorfeus
149
+ - bin/yandle
150
+ - lib/isomorfeus/cli.rb
151
+ - lib/isomorfeus/console.rb
152
+ - lib/isomorfeus/installer.rb
153
+ - lib/isomorfeus/installer/databases/arangodb.rb
154
+ - lib/isomorfeus/installer/new_project.rb
155
+ - lib/isomorfeus/installer/options_mangler.rb
156
+ - lib/isomorfeus/installer/rack_servers.rb
157
+ - lib/isomorfeus/installer/templates/.gitignore.erb
158
+ - lib/isomorfeus/installer/templates/.gitkeep.erb
159
+ - lib/isomorfeus/installer/templates/Gemfile.erb
160
+ - lib/isomorfeus/installer/templates/Procfile.erb
161
+ - lib/isomorfeus/installer/templates/ProcfileDebug.erb
162
+ - lib/isomorfeus/installer/templates/anonymous_policy.rb.erb
163
+ - lib/isomorfeus/installer/templates/app.rb.erb
164
+ - lib/isomorfeus/installer/templates/app_loader.rb.erb
165
+ - lib/isomorfeus/installer/templates/application.css.erb
166
+ - lib/isomorfeus/installer/templates/application.js.erb
167
+ - lib/isomorfeus/installer/templates/application_common.js.erb
168
+ - lib/isomorfeus/installer/templates/application_ssr.js.erb
169
+ - lib/isomorfeus/installer/templates/application_web_worker.js.erb
170
+ - lib/isomorfeus/installer/templates/arango_config.rb.erb
171
+ - lib/isomorfeus/installer/templates/config.ru.erb
172
+ - lib/isomorfeus/installer/templates/debug.js.erb
173
+ - lib/isomorfeus/installer/templates/development.js.erb
174
+ - lib/isomorfeus/installer/templates/development_ssr.js.erb
175
+ - lib/isomorfeus/installer/templates/hello_component.rb.erb
176
+ - lib/isomorfeus/installer/templates/iodine_config.rb.erb
177
+ - lib/isomorfeus/installer/templates/isomorfeus_loader.rb.erb
178
+ - lib/isomorfeus/installer/templates/isomorfeus_web_worker_loader.rb.erb
179
+ - lib/isomorfeus/installer/templates/my_app.rb.erb
180
+ - lib/isomorfeus/installer/templates/navigation_links.rb.erb
181
+ - lib/isomorfeus/installer/templates/not_found_404_component.rb.erb
182
+ - lib/isomorfeus/installer/templates/package.json.erb
183
+ - lib/isomorfeus/installer/templates/production.js.erb
184
+ - lib/isomorfeus/installer/templates/spec_helper.rb.erb
185
+ - lib/isomorfeus/installer/templates/test_spec.rb.erb
186
+ - lib/isomorfeus/installer/templates/welcome_component.rb.erb
187
+ - lib/isomorfeus/version.rb
188
+ homepage: http://isomorfeus.com
189
+ licenses:
190
+ - MIT
191
+ metadata: {}
192
+ post_install_message:
193
+ rdoc_options: []
194
+ require_paths:
195
+ - lib
196
+ required_ruby_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ required_rubygems_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">"
204
+ - !ruby/object:Gem::Version
205
+ version: 1.3.1
206
+ requirements: []
207
+ rubygems_version: 3.0.6
208
+ signing_key:
209
+ specification_version: 4
210
+ summary: Create new isomorfeus-framework applications with ease.
211
+ test_files: []