isomorfeus-installer 1.0.0.delta1 → 1.0.0.delta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/bin/isomorfeus +8 -122
  4. data/lib/isomorfeus/installer/cli.rb +26 -0
  5. data/lib/isomorfeus/installer/databases/arangodb.rb +4 -1
  6. data/lib/isomorfeus/installer/databases/mysql.rb +18 -2
  7. data/lib/isomorfeus/installer/databases/neo4j.rb +7 -2
  8. data/lib/isomorfeus/installer/databases/postgresql.rb +18 -2
  9. data/lib/isomorfeus/installer/databases/sqlite.rb +22 -0
  10. data/lib/isomorfeus/installer/new_project.rb +56 -0
  11. data/lib/isomorfeus/installer/options_mangler.rb +49 -0
  12. data/lib/isomorfeus/installer/other_modules.rb +11 -0
  13. data/lib/isomorfeus/installer/rack_servers.rb +19 -0
  14. data/{Gemfile → lib/isomorfeus/installer/templates/.gitkeep.erb} +0 -0
  15. data/lib/isomorfeus/installer/templates/Gemfile.erb +18 -8
  16. data/lib/isomorfeus/installer/templates/Procfile.erb +2 -2
  17. data/lib/isomorfeus/installer/templates/ProcfileDebug.erb +2 -0
  18. data/lib/isomorfeus/installer/templates/actioncable/actioncable_ru.erb +3 -0
  19. data/lib/isomorfeus/installer/templates/app.rb.erb +35 -0
  20. data/lib/isomorfeus/installer/templates/app_loader.rb.erb +13 -0
  21. data/lib/isomorfeus/installer/{spectre.rb → templates/application.css.erb} +0 -0
  22. data/lib/isomorfeus/installer/templates/application.js.erb +15 -23
  23. data/lib/isomorfeus/installer/templates/application_common.js.erb +23 -0
  24. data/lib/isomorfeus/installer/templates/application_debug.js.erb +9 -0
  25. data/lib/isomorfeus/installer/templates/application_ssr.js.erb +18 -0
  26. data/lib/isomorfeus/installer/templates/application_web_worker.js.erb +5 -0
  27. data/lib/isomorfeus/installer/templates/config_ru.erb +3 -0
  28. data/lib/isomorfeus/installer/templates/isomorfeus_loader.rb.erb +11 -2
  29. data/lib/isomorfeus/installer/templates/isomorfeus_web_worker_loader.rb.erb +2 -0
  30. data/lib/isomorfeus/installer/templates/my_app.rb.erb +1 -1
  31. data/lib/isomorfeus/installer/templates/package.json.erb +20 -6
  32. data/lib/isomorfeus/installer/templates/spec_helper.rb.erb +19 -0
  33. data/lib/isomorfeus/installer/templates/test_spec.rb.erb +13 -0
  34. data/lib/isomorfeus/installer/transport_stores/redis.rb +14 -0
  35. data/lib/isomorfeus/installer/transports/actioncable.rb +33 -1
  36. data/lib/isomorfeus/installer.rb +250 -130
  37. data/readme.md +2 -5
  38. metadata +125 -30
  39. data/isomorfeus-installer.gemspec +0 -19
  40. data/lib/isomorfeus/installer/asset_bundlers/opal_webpack_loader.rb +0 -103
  41. data/lib/isomorfeus/installer/databases/none.rb +0 -11
  42. data/lib/isomorfeus/installer/frameworks/cuba.rb +0 -26
  43. data/lib/isomorfeus/installer/frameworks/rails.rb +0 -78
  44. data/lib/isomorfeus/installer/frameworks/roda.rb +0 -26
  45. data/lib/isomorfeus/installer/frameworks/sinatra.rb +0 -26
  46. data/lib/isomorfeus/installer/templates/cuba/config_ru.erb +0 -48
  47. data/lib/isomorfeus/installer/templates/owl/development.js.erb +0 -145
  48. data/lib/isomorfeus/installer/templates/owl/production.js.erb +0 -93
  49. data/lib/isomorfeus/installer/templates/owl/test.js.erb +0 -0
  50. data/lib/isomorfeus/installer/templates/rails/application.html.erb.head +0 -6
  51. data/lib/isomorfeus/installer/templates/rails/application.html.erb.tail +0 -6
  52. data/lib/isomorfeus/installer/templates/rails/application_controller.rb +0 -5
  53. data/lib/isomorfeus/installer/templates/rails/application_helper.rb.erb +0 -3
  54. data/lib/isomorfeus/installer/templates/rails/assets.rb.erb +0 -1
  55. data/lib/isomorfeus/installer/templates/rails/basic-react.rb +0 -453
  56. data/lib/isomorfeus/installer/templates/rails/index.html +0 -1
  57. data/lib/isomorfeus/installer/templates/rails/routes.rb +0 -5
  58. data/lib/isomorfeus/installer/templates/roda/config_ru.erb +0 -39
  59. data/lib/isomorfeus/installer/templates/sinatra/config_ru.erb +0 -38
  60. data/lib/isomorfeus/installer/transport.rb +0 -0
  61. data/lib/isomorfeus/installer/transport_store.rb +0 -0
@@ -0,0 +1,5 @@
1
+ import init_app from 'isomorfeus_web_worker_loader.rb';
2
+ init_app();
3
+ Opal.load('isomorfeus_web_worker_loader');
4
+
5
+ if (module.hot) { module.hot.accept(); }
@@ -0,0 +1,3 @@
1
+ require './<%= app_require %>'
2
+
3
+ run <%= app_class %>.app
@@ -2,7 +2,16 @@ require 'opal'
2
2
  require 'opal-autoloader'
3
3
  require 'isomorfeus-redux'
4
4
  require 'isomorfeus-react'
5
+ <% if use_transport %>
6
+ require 'isomorfeus-transport'
7
+ <%= transport_requires %>
8
+ <% end %>
9
+ <% if use_database %>require 'isomorfeus-record'<% end %>
10
+ <% if use_policy %>require 'isomorfeus-policy'<% end %>
11
+ <% if use_operation %>require 'isomorfeus-operation'<% end %>
12
+ <% if use_i18n %>require 'isomorfeus-i18n'<% end %>
5
13
 
14
+ <% if use_policy %>require_tree 'policies'<% end %>
15
+ <% if use_database %>require_tree 'models'<% end %>
16
+ <% if use_operation %>require_tree 'operations'<% end %>
6
17
  require_tree 'components'
7
-
8
- Isomorfeus::TopLevel.on_ready_mount(<%= app_name %>)
@@ -0,0 +1,2 @@
1
+ require 'opal'
2
+ require 'opal-autoloader'
@@ -1,4 +1,4 @@
1
- class <%= app_name %> < LucidApp::Base
1
+ class <%= app_class %> < LucidApp::Base
2
2
  render do
3
3
  # here may be a router for example:
4
4
  # DIV do
@@ -2,20 +2,34 @@
2
2
  "name": "<%= application_name %>",
3
3
  "private": true,
4
4
  "dependencies": {
5
- <%= npm_packages %>
5
+ "opal-webpack-loader": "^0.8.3",
6
6
  "react": "16.6",
7
7
  "react-dom": "16.6",
8
- "react-hot-loader": "^4.3.11",
9
8
  "react-router": "^4.3.1",
10
9
  "react-router-dom": "^4.3.1",
11
10
  "redux": "^4.0.1"
12
11
  },
13
- <%= scripts %>
12
+ "scripts": {
13
+ "debug": "webpack-dev-server --config=webpack/debug.js",
14
+ "development": "webpack-dev-server --config=webpack/development.js",
15
+ "production_build": "webpack --config=webpack/production.js"
16
+ },
14
17
  "devDependencies": {
18
+ "cache-loader": "^3.0.0",
19
+ "chokidar": "^2.1.5",
15
20
  "compression-webpack-plugin": "^2.0.0",
16
- "webpack": "^4.27.0",
17
- "webpack-cli": "^3.1.1",
18
- "webpack-dev-server": "^3.1.10",
21
+ "css-loader": "^2.1.1",
22
+ "extra-watch-webpack-plugin": "^1.0.3",
23
+ "file-loader": "^1.1.11",
24
+ "jsdom": "14.0.0",
25
+ "node-sass": "^4.12.0",
26
+ "puppeteer": "1.14.0",
27
+ "sass-loader": "^7.1.0",
28
+ "style-loader": "^0.23.1",
29
+ "terser-webpack-plugin": "^1.2.3",
30
+ "webpack": "^4.30.0",
31
+ "webpack-cli": "^3.3.0",
32
+ "webpack-dev-server": "^3.3.1",
19
33
  "webpack-manifest-plugin": "^2.0.4"
20
34
  }
21
35
  }
@@ -0,0 +1,19 @@
1
+ ENV['NODE_PATH'] = File.join(File.expand_path('..', __dir__), 'node_modules')
2
+ ENV['<%= project_env %>'] = 'production'
3
+ require 'bundler/setup'
4
+ require 'rspec'
5
+ require 'rspec/expectations'
6
+ require 'isomorfeus-puppetmaster'
7
+ require_relative '../<%= app_require %>'
8
+
9
+ ASSETS_COMPILED ||= `yarn run production_build`
10
+
11
+ Isomorfeus::Puppetmaster.download_path = File.join(Dir.pwd, 'download_path_tmp')
12
+ Isomorfeus::Puppetmaster.driver = :chromium
13
+ Isomorfeus::Puppetmaster.app = <%= app_class %>
14
+ Isomorfeus::Puppetmaster.boot_app
15
+
16
+ RSpec.configure do |config|
17
+ config.include Isomorfeus::Puppetmaster::DSL
18
+ end
19
+
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'opal-webpack-loader compiled successfully' do
4
+ it 'and opal code can be executed in the browser' do
5
+ doc = visit('/')
6
+ expect(doc.evaluate_script('1 + 4')).to eq(5)
7
+ expect(doc.evaluate_script('typeof Opal')).to include('object')
8
+ result = doc.evaluate_ruby do
9
+ 1 + 5
10
+ end
11
+ expect(result).to eq(6)
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Isomorfeus
2
+ module Installer
3
+ module TransportStores
4
+ module Redis
5
+
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ Isomorfeus::Installer.add_transport_store_module('redis', {
12
+ gems: [ { name: 'isomorfeus-transport-store-redis', version: "~> #{Isomorfeus::Installer::VERSION}" } ],
13
+ installer: Isomorfeus::Installer::TransportStores::Redis
14
+ })
@@ -2,10 +2,42 @@ module Isomorfeus
2
2
  module Installer
3
3
  module Transports
4
4
  module ActionCable
5
+ def self.install(root)
6
+ # data_hash = { requires: Isomorfeus::Installer.create_requires }
7
+ # Isomorfeus::Installer.create_file_from_template(File.join('actioncable', 'actioncable_ru.erb'), 'actioncable.ru', data_hash)
8
+ end
5
9
 
10
+ def self.config
11
+ 'ActionCable::Server::Base.config.logger = ActiveSupport::Logger.new(STDOUT)'
12
+ end
13
+
14
+ def self.js_import
15
+ "import ActionCable from 'actioncable';"
16
+ end
17
+
18
+ def self.js_global
19
+ "global.ActionCable = ActionCable;"
20
+ end
21
+
22
+ def self.rack_app
23
+ 'ActionCable.server'
24
+ end
25
+
26
+ def self.rack_app_mount_path
27
+ 'websocket'
28
+ end
29
+
30
+ def self.requires
31
+ "require 'isomorfeus-transport-actioncable'"
32
+ end
6
33
  end
7
34
  end
8
35
  end
9
36
  end
10
37
 
11
- Isomorfeus::Installer.add_transport('actioncable', {})
38
+ Isomorfeus::Installer.add_transport_module('actioncable', {
39
+ gems: [ { name: 'isomorfeus-transport', version: "~> #{Isomorfeus::Installer::VERSION}" },
40
+ { name: 'isomorfeus-transport-actioncable', version: "~> #{Isomorfeus::Installer::VERSION}" } ],
41
+ npms: [ { name: 'actioncable', version: '^5.2.2' } ],
42
+ installer: Isomorfeus::Installer::Transports::ActionCable
43
+ })
@@ -1,80 +1,134 @@
1
1
  module Isomorfeus
2
2
  module Installer
3
-
3
+ VERSION = File.read(File.expand_path("../../../../ISOMORFEUS_VERSION", __dir__)).strip
4
4
  # driver support
5
5
 
6
- def self.add_asset_bundler(name, props)
7
- asset_bundlers[name] = props
8
- end
9
-
10
6
  def self.add_database(name, props)
11
7
  databases[name] = props
12
8
  end
13
9
 
14
- def self.add_framework(name, props)
15
- frameworks[name] = props
10
+ def self.add_i18n_module(name, props)
11
+ i18ns[name] = props
12
+ end
13
+
14
+ def self.add_operation_module(name, props)
15
+ operations[name] = props
16
+ end
17
+
18
+ def self.add_policy_module(name, props)
19
+ policies[name] = props
20
+ end
21
+
22
+ def self.add_rack_server(name, props)
23
+ rack_servers[name] = props
16
24
  end
17
25
 
18
- def self.add_transport(name, props)
26
+ def self.add_transport_module(name, props)
19
27
  transports[name] = props
20
28
  end
21
29
 
22
- def self.asset_bundler
23
- @asset_bundler
30
+ def self.add_transport_store_module(name, props)
31
+ transport_stores[name] = props
24
32
  end
25
33
 
26
- def self.asset_bundler=(asset_b)
27
- @asset_bundler = asset_b
34
+ class << self
35
+ # application options
36
+ attr_reader :app_class
37
+ attr_reader :app_require
38
+ attr_reader :component_name
39
+ attr_accessor :database
40
+ attr_accessor :framework
41
+ attr_accessor :i18n
42
+ attr_accessor :operation
43
+ attr_accessor :policy
44
+ attr_reader :project_env
45
+ attr_reader :project_name
46
+ attr_accessor :rack_server
47
+ attr_accessor :transport
48
+ attr_accessor :transport_store
49
+
50
+ # installer options
51
+ attr_reader :options
28
52
  end
29
53
 
30
- def self.asset_bundlers
31
- @asset_bundlers ||= {}
54
+ def self.set_project_names(pro_name)
55
+ @project_name = pro_name.underscore
56
+ @app_class = pro_name.camelize + 'App'
57
+ @app_require = pro_name.underscore + '_app'
58
+ @component_name = pro_name.camelize + 'Component'
59
+ @project_env = pro_name.underscore.upcase + '_ENV'
32
60
  end
33
61
 
34
- def self.databases
35
- @databases ||= {}
62
+ def self.options=(options)
63
+ Isomorfeus::Installer::OptionsMangler.mangle_options(options)
64
+ puts "options: #{options}"
65
+ @options = options
36
66
  end
37
67
 
38
- def self.frameworks
39
- @frameworks ||= {}
68
+ def self.sorted_databases
69
+ databases.keys.sort
40
70
  end
41
71
 
42
- def self.framework
43
- @framework
72
+ def self.sorted_i18ns
73
+ i18ns.keys.sort
44
74
  end
45
75
 
46
- def self.framework=(frame_w)
47
- @framework = frame_w
76
+ def self.sorted_operations
77
+ operations.keys.sort
48
78
  end
49
79
 
50
- def self.transports
51
- @transports ||= {}
80
+ def self.sorted_policies
81
+ policies.keys.sort
52
82
  end
53
83
 
54
- def self.structure=(struct)
55
- @structure = struct
84
+ def self.sorted_rack_servers
85
+ rack_servers.keys.sort
56
86
  end
57
87
 
58
- def self.structure
59
- @structure
88
+ def self.sorted_transports
89
+ transports.keys
60
90
  end
61
91
 
62
- # installer options and config
92
+ def self.sorted_transport_stores
93
+ transport_stores.keys
94
+ end
63
95
 
64
- def self.options
65
- @options
96
+ def self.databases
97
+ @databases ||= {}
66
98
  end
67
99
 
68
- def self.options=(opts)
69
- @options = opts
100
+ def self.i18ns
101
+ @i18ns ||= {}
70
102
  end
71
103
 
104
+ def self.operations
105
+ @operations ||= {}
106
+ end
107
+
108
+ def self.policies
109
+ @policies ||= {}
110
+ end
111
+
112
+ def self.rack_servers
113
+ @rack_servers ||= {}
114
+ end
115
+
116
+ def self.transports
117
+ @transports ||= {}
118
+ end
119
+
120
+ def self.transport_stores
121
+ @transport_stores ||= {}
122
+ end
123
+
124
+ # installer options and config
125
+
72
126
  def self.module_directories
73
- %w[asset_bundlers databases frameworks transports]
127
+ %w[databases transports transport_stores]
74
128
  end
75
129
 
76
130
  # installer paths
77
- #
131
+
78
132
  def self.base_path
79
133
  @base_path ||= File.realpath(File.join(File.dirname(File.realpath(__FILE__)), 'installer'))
80
134
  end
@@ -89,57 +143,45 @@ module Isomorfeus
89
143
  File.join('public', 'assets')
90
144
  end
91
145
 
92
- def self.entrypoint
93
- 'application.js'
146
+ def self.entrypoint_path(entrypoint)
147
+ File.join(isomorfeus_path, 'imports', entrypoint)
94
148
  end
95
149
 
96
- def self.entrypoint_path
97
- if structure == :app_iso
98
- File.join('app', 'assets', 'javascripts', entrypoint)
99
- else
100
- File.join('assets', 'javascripts', entrypoint)
101
- end
150
+ def self.isomorfeus_path
151
+ 'isomorfeus'
102
152
  end
103
153
 
104
- def self.isomorfeus_path
105
- if structure == :app_iso
106
- File.join('app', 'isomorfeus')
107
- else
108
- 'isomorfeus'
109
- end
154
+ def self.stylesheet_path(stylesheet)
155
+ File.join(isomorfeus_path, 'styles', stylesheet)
110
156
  end
111
157
 
112
- def self.stylesheets_path
113
- if structure == :app_iso
114
- File.join('app', 'assets', 'stylesheets')
115
- else
116
- File.join('assets', 'stylesheets')
117
- end
158
+ def self.middlewares_includes
159
+ 'extend Isomorfeus::Transport::Middlewares'
118
160
  end
119
161
 
120
162
  # install helpers
121
163
 
164
+ def self.generate_gem_line(gem_hash)
165
+ line = "gem '#{gem_hash[:name]}', '#{gem_hash[:version]}'"
166
+ line << ", require: false" if gem_hash.has_key?(:require) && !gem_hash[:require]
167
+ line << "\n"
168
+ end
169
+
122
170
  def self.create_directories
123
- if structure == :app_iso
124
- Dir.mkdir('config') unless Dir.exist?('config')
125
- Dir.mkdir('app') unless Dir.exist?('app')
126
- Dir.chdir('app')
171
+ create_directory(File.join(isomorfeus_path, 'imports'))
172
+ create_directory(File.join(isomorfeus_path, 'components'))
173
+ create_directory(File.join(isomorfeus_path, 'models'))
174
+ create_directory(File.join(isomorfeus_path, 'operations'))
175
+ create_directory(File.join(isomorfeus_path, 'policies'))
176
+ create_directory(File.join(isomorfeus_path, 'styles'))
177
+ create_directory('spec')
178
+ end
179
+
180
+ def self.create_directory(directory)
181
+ unless Dir.exist?(directory)
182
+ puts "Creating directory #{directory}."
183
+ FileUtils.mkdir_p(directory)
127
184
  end
128
- Dir.mkdir('isomorfeus') unless Dir.exist?('isomorfeus')
129
- Dir.chdir('isomorfeus')
130
- Dir.mkdir('components') unless Dir.exist?('components')
131
- if use_database?
132
- Dir.mkdir('models') unless Dir.exist?('models')
133
- end
134
-
135
- Dir.chdir('..') if structure == :app_iso
136
- Dir.chdir('..')
137
-
138
- Dir.mkdir('public') unless Dir.exist?('public')
139
- Dir.mkdir('public/assets') unless Dir.exist?('public/assets')
140
- Dir.mkdir('assets') unless Dir.exist?('assets')
141
- Dir.mkdir('assets/javascripts') unless Dir.exist?('assets/javascripts')
142
- Dir.mkdir('assets/stylesheets') unless Dir.exist?('assets/stylesheets')
143
185
  end
144
186
 
145
187
  def self.create_file_from_template(template_path, target_file_path, data_hash)
@@ -149,86 +191,164 @@ module Isomorfeus
149
191
  File.write(target_file_path + ext, result, mode: 'w')
150
192
  end
151
193
 
152
- def self.create_entrypoint
153
- data_hash = {}
154
- create_file_from_template(entrypoint + '.erb', entrypoint_path, data_hash)
155
- end
156
-
157
- def self.create_gemfile(framework_gems, asset_bundler_gems)
158
- asset_bundler_gems_result = ''
159
- asset_bundler_gems.each { |gem| asset_bundler_gems_result << "gem '#{gem[:name]}', '#{gem[:version]}'\n" } if asset_bundler_gems
160
- if framework_gems == :has_gemfile
161
- framework_gems_result = File.read('Gemfile')
162
- File.delete('Gemfile')
163
- data_hash = { asset_bundler_gems: asset_bundler_gems_result,
164
- framework_gems: framework_gems_result,
165
- skip_header: true }
166
- else
167
- framework_gems_result = ''
168
- framework_gems.each { |gem| framework_gems_result << "gem '#{gem[:name]}', '#{gem[:version]}'\n" }
169
- data_hash = { asset_bundler_gems: asset_bundler_gems_result,
170
- framework_gems: framework_gems_result }
194
+ def self.install_framework
195
+ data_hash = { app_class: app_class,
196
+ isomorfeus_config: create_isomorfeus_config,
197
+ middlewares: create_middlewares,
198
+ middlewares_includes: middlewares_includes,
199
+ transport_rack_app_mount_path: transport&.rack_app_mount_path,
200
+ transport_rack_app: transport&.rack_app,
201
+ transport_config: transport&.config,
202
+ use_transport: use_transport?,
203
+ use_transport_rack_app: use_transport_rack_app? }
204
+ create_file_from_template('app.rb.erb', "#{@project_name}_app.rb", data_hash)
205
+ data_hash = { app_require: app_require, app_class: app_class }
206
+ create_file_from_template('config_ru.erb', 'config.ru', data_hash)
207
+ data_hash = { project_env: @project_env }
208
+ create_file_from_template(File.join('app_loader.rb.erb'), 'app_loader.rb', data_hash)
209
+ end
210
+
211
+ def self.install_isomorfeus_entries
212
+ data_hash = { app_class: app_class,
213
+ use_database: use_database?,
214
+ use_i18n: use_i18n?,
215
+ use_operation: use_operation?,
216
+ use_policy: use_policy?,
217
+ use_transport: use_transport?,
218
+ transport_requires: use_transport? ? transport.requires : nil }
219
+
220
+ create_file_from_template('isomorfeus_loader.rb.erb', File.join(isomorfeus_path, 'isomorfeus_loader.rb'), data_hash)
221
+ create_file_from_template('isomorfeus_web_worker_loader.rb.erb', File.join(isomorfeus_path, 'isomorfeus_web_worker_loader.rb'), data_hash)
222
+ end
223
+
224
+ def self.install_js_entries
225
+
226
+ data_hash = { use_transport: use_transport_import?,
227
+ transport_import: (use_transport_import? ? transport.js_import : nil),
228
+ transport_global: (use_transport_import? ? transport.js_global : nil) }
229
+ create_file_from_template('application.js.erb', entrypoint_path('application.js'), data_hash)
230
+ create_file_from_template('application_common.js.erb', entrypoint_path('application_common.js'), data_hash)
231
+ create_file_from_template('application_debug.js.erb', entrypoint_path('application_debug.js'), data_hash)
232
+ create_file_from_template('application_ssr.js.erb', entrypoint_path('application_ssr.js'), data_hash)
233
+ create_file_from_template('application_web_worker.js.erb', entrypoint_path('application_web_worker.js'), data_hash)
234
+ end
235
+
236
+ def self.install_styles
237
+ create_file_from_template('application.css.erb', stylesheet_path('application.css'), {})
238
+ end
239
+
240
+ def self.create_gemfile
241
+ rack_server_gems = ''
242
+ Isomorfeus::Installer.rack_servers[options[:rack_server]]&.fetch(:gems)&.each do |gem|
243
+ rack_server_gems << generate_gem_line(gem)
244
+ end
245
+ transport_gems = ''
246
+ Isomorfeus::Installer.transports[options[:transport]]&.fetch(:gems)&.each do |gem|
247
+ transport_gems << generate_gem_line(gem)
171
248
  end
249
+ Isomorfeus::Installer.transport_stores[options[:transport_store]]&.fetch(:gems)&.each do |gem|
250
+ transport_gems << generate_gem_line(gem)
251
+ end
252
+ database_gems = ''
253
+ Isomorfeus::Installer.databases[options[:database]]&.fetch(:gems)&.each do |gem|
254
+ database_gems << generate_gem_line(gem)
255
+ end
256
+ i18n_gems = ''
257
+ Isomorfeus::Installer.i18ns['i18n']&.fetch(:gems)&.each do |gem|
258
+ i18n_gems << generate_gem_line(gem)
259
+ end
260
+ operation_gems = ''
261
+ Isomorfeus::Installer.operations['operation']&.fetch(:gems)&.each do |gem|
262
+ operation_gems << generate_gem_line(gem)
263
+ end
264
+ policy_gems = ''
265
+ Isomorfeus::Installer.policies['policy']&.fetch(:gems)&.each do |gem|
266
+ policy_gems << generate_gem_line(gem)
267
+ end
268
+
269
+ data_hash = { database_gems: database_gems.chop,
270
+ i18n_gems: i18n_gems.chop,
271
+ operation_gems: operation_gems.chop,
272
+ policy_gems: policy_gems.chop,
273
+ rack_server_gems: rack_server_gems.chop,
274
+ transport_gems: transport_gems.chop }
172
275
  create_file_from_template('Gemfile.erb', 'Gemfile', data_hash)
173
276
  end
174
277
 
175
- def self.create_loader(app_name)
176
- data_hash = { app_name: app_name }
177
- iso_entry = File.join(isomorfeus_path, 'isomorfeus_loader.rb')
178
- create_file_from_template('isomorfeus_loader.rb.erb', iso_entry, data_hash)
278
+ def self.create_component
279
+ data_hash = { component_name: component_name }
280
+ create_file_from_template('my_component.rb.erb',
281
+ File.join(isomorfeus_path, 'components', component_name.underscore + '.rb'), data_hash)
282
+ end
283
+
284
+ def self.create_middlewares
285
+ "use_isomorfeus_middlewares" if options.has_key?(:transport)
286
+ end
287
+
288
+ def self.create_isomorfeus_config
289
+ '' # "Isomorfeus.env = ENV['#{project_env}']"
179
290
  end
180
291
 
181
292
  def self.create_package_json
182
293
  npms = ''
183
- if options.has_key?(:asset_bundler) && asset_bundlers[options[:asset_bundler]].has_key?(:npms)
184
- asset_bundlers[options[:asset_bundler]][:npms].each do |npm|
185
- npms << "\"#{npm[:name]}\": \"#{npm[:version]}\",\n"
294
+ if use_transport? && transports[options[:transport]].has_key?(:npms)
295
+ transports[options[:transport]][:npms].each do |npm|
296
+ npms << " \"#{npm[:name]}\": \"#{npm[:version]}\",\n"
186
297
  end
187
298
  end
188
- data_hash = { application_name: options[:new],
189
- scripts: asset_bundler.respond_to?(:package_scripts) ? asset_bundler.package_scripts : '',
190
- npm_packages: npms }
299
+ data_hash = { application_name: app_class,
300
+ npm_packages: npms.chop }
191
301
  create_file_from_template('package.json.erb', 'package.json', data_hash)
192
302
  end
193
303
 
194
304
  def self.create_procfile
195
- data_hash = { framework_start_command: framework.start_command,
196
- asset_bundler_start_command: asset_bundler.start_command }
305
+ data_hash = { rack_server_start_command: rack_server[:start_command] }
197
306
  create_file_from_template('Procfile.erb', 'Procfile', data_hash)
307
+ create_file_from_template('ProcfileDebug.erb', 'ProcfileDebug', data_hash)
198
308
  end
199
309
 
200
- def self.create_component(component_name)
201
- data_hash = { component_name: component_name }
202
- create_file_from_template('my_component.rb.erb',File.join(isomorfeus_path, 'components', component_name.underscore + '.rb'), data_hash)
310
+ def self.create_spec
311
+ data_hash = { app_class: app_class, app_require: app_require, project_env: project_env }
312
+ create_file_from_template('spec_helper.rb.erb', File.join('spec', 'spec_helper.rb'), data_hash)
313
+ create_file_from_template('test_spec.rb.erb', File.join('spec', 'test_spec.rb'), {})
203
314
  end
204
315
 
205
- def self.create_toplevel(app_name, component_name)
206
- data_hash = { app_name: app_name, component_name: component_name }
207
- create_file_from_template('my_app.rb.erb',File.join(isomorfeus_path, 'components', app_name.underscore + '.rb'), data_hash)
316
+ def self.create_toplevel
317
+ data_hash = { app_class: app_class, component_name: component_name }
318
+ create_file_from_template('my_app.rb.erb',
319
+ File.join(isomorfeus_path, 'components', app_class.underscore + '.rb'), data_hash)
208
320
  end
209
321
 
210
- def self.create_requires
211
- "require 'bundler/setup'\nBundler.require(:default)\n"
322
+ def self.use_asset_bundler?
323
+ options.has_key?('asset_bundler')
212
324
  end
213
325
 
214
- # def self.require_record?
215
- # @require_record
216
- # end
217
- #
218
- # def self.require_operation?
219
- # @require_operation
220
- # end
221
- #
222
- # def self.require_policy?
223
- # @require_policy
224
- # end
225
- #
226
- # def self.require_spectre?
227
- # @require_spectre
228
- # end
229
-
230
326
  def self.use_database?
231
- options.has_key?(:database) && options[:database] != 'none'
327
+ options.has_key?('database')
328
+ end
329
+
330
+ def self.use_i18n?
331
+ options['i18n']
332
+ end
333
+
334
+ def self.use_operation?
335
+ options['operation']
336
+ end
337
+
338
+ def self.use_policy?
339
+ options['policy']
340
+ end
341
+
342
+ def self.use_transport?
343
+ options.has_key?('transport')
344
+ end
345
+
346
+ def self.use_transport_import?
347
+ use_transport? && transport&.respond_to?(:js_import)
348
+ end
349
+
350
+ def self.use_transport_rack_app?
351
+ transport&.respond_to?(:rack_app)
232
352
  end
233
353
  end
234
354
  end
data/readme.md CHANGED
@@ -2,11 +2,8 @@
2
2
 
3
3
  Create new isomorfeus applications with ease.
4
4
 
5
- #### Supported Frameworks
6
- - Cuba
7
- - Rails
8
- - Roda
9
- - Sinatra
5
+ ### Community and Support
6
+ At the [Isomorfeus Framework Project](http://isomorfeus.com)
10
7
 
11
8
  #### Supported Isomorfeus modules
12
9
  - isomorfeus-react