rails-hyperstack 1.0.alpha1.4 → 1.0.alpha1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03702710230166a76d49beb8d461771b8e0ea8f51d96189860742bd7eab0cac4
4
- data.tar.gz: 322d226a3ca3c5462bdda5360ea6e5a10e6feac9a0bce9f3faf299f0fc76b850
3
+ metadata.gz: 8c8b7f53db3107e49c7b59eab1b4cc9d5548ef6cfee842fb971fa516b1b75469
4
+ data.tar.gz: b05b41840ccf479ff2011fa70dc35a879715100d99a4e33d2a1d1817d9c9e330
5
5
  SHA512:
6
- metadata.gz: ed06a20e392fe2bcc404ff125a15d9abcdc2f762cd6a2e872b626e24d70f3bb9b2da71b812a450b47a4a6c5bac47440d4171f09c2fb6f6cb291e1baf711807f8
7
- data.tar.gz: e21862ee2f9807bb5a4d730622ad9d34db6b05414759bb72c0e82157ac7a886826cd9b5ac51204f21492e80dd4675d2fcfc46d04cc3821283f082ff87cd79876
6
+ metadata.gz: 2c1a4c77d0def6a0895879f776ede450bc63e33ff96d555df70a19e33b666c9f510cd8c96bdad218446477386c1d31ac51961daae461189274b4024cbaf5513e
7
+ data.tar.gz: aa53c533efc6d297c77a3f34ae5f2f0385868685270f1c7f5742b75d980d61a6f32dfda4ccd9137edd0abdda3a471ba39b2ba86973afdc5709dc33401625fc2a
@@ -1,20 +1,7 @@
1
- require 'rails/generators'
2
1
  module Hyper
3
- class Component < Rails::Generators::Base
4
- source_root File.expand_path('../templates', __FILE__)
5
-
6
- argument :components, type: :array
7
- def create_component_file
8
- self.components.each do |component|
9
- component_array = component.split('::')
10
- @modules = component_array[0..-2]
11
- @file_name = component_array.last
12
- @indent = 0
13
- template 'component_template.rb',
14
- File.join('app/hyperstack/components',
15
- @modules.map(&:downcase).join('/'),
16
- "#{@file_name.underscore}.rb")
17
- end
2
+ class Component < GeneratorBase
3
+ def add_component
4
+ create_component_file 'component_template.rb'
18
5
  end
19
6
  end
20
7
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+ module Hyper
3
+ class GeneratorBase < Rails::Generators::Base
4
+ class << self
5
+ alias rails_inherited inherited
6
+ def inherited(child)
7
+ rails_inherited(child)
8
+ child.class_eval do
9
+ source_root File.expand_path('../templates', __FILE__)
10
+ argument :components, type: :array
11
+ class_option 'base-class', :default => nil # will pull in value from config setting
12
+ class_option 'add-route', :default => nil
13
+ class_option 'no-help', :default => nil
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,23 +1,7 @@
1
- require 'rails/generators'
2
1
  module Hyper
3
- class Router < Rails::Generators::Base
4
- source_root File.expand_path('../templates', __FILE__)
5
-
6
- argument :component, type: :string
7
- class_option :path, type: :string, default: '/(*other)'
8
- def create_component_file
9
- component_array = component.split('::')
10
- @modules = component_array[0..-2]
11
- @file_name = component_array.last
12
- @indent = 0
13
- template 'router_template.rb',
14
- File.join('app/hyperstack/components',
15
- @modules.map(&:downcase).join('/'),
16
- "#{@file_name.underscore}.rb")
17
- end
18
-
19
- def add_route
20
- route "get '#{options['path']}', to: 'hyperstack##{@file_name.underscore}'"
2
+ class Router < GeneratorBase
3
+ def add_router_component
4
+ create_component_file 'router_template.rb'
21
5
  end
22
6
  end
23
7
  end
@@ -1,15 +1,24 @@
1
1
  <%- @modules.each do |module_name| %><%= " "* @indent %>module <%= module_name.camelize %><%- @indent += 1 %>
2
- <%- end %><%=" "* @indent %>class <%= @file_name %> < Hyperstack::Component
3
-
2
+ <%- end %><%=" "* @indent %>class <%= @file_name %> < <%= @component_base_class %>
3
+ <%- unless @no_help %>
4
4
  <%=" "* @indent %> # param :my_param
5
5
  <%=" "* @indent %> # param param_with_default: "default value"
6
6
  <%=" "* @indent %> # param :param_with_default2, default: "default value" # alternative syntax
7
7
  <%=" "* @indent %> # param :param_with_type, type: Hash
8
8
  <%=" "* @indent %> # param :array_of_hashes, type: [Hash]
9
- <%=" "* @indent %> # collect_other_params_as :attributes # collects all other params into a hash
9
+ <%=" "* @indent %> # other :attributes # collects all other params into a hash
10
+ <%=" "* @indent %> # fires :callback # creates a callback param
11
+
12
+ <%=" "* @indent %> # access params using the param name
13
+ <%=" "* @indent %> # fire a callback using the callback name followed by a !
14
+
15
+ <%=" "* @indent %> # state is kept and read as normal instance variables
16
+ <%=" "* @indent %> # but when changing state prefix the statement with `mutate`
17
+ <%=" "* @indent %> # i.e. mutate @my_state = 12
18
+ <%=" "* @indent %> # mutate @my_other_state[:bar] = 17
10
19
 
11
- <%=" "* @indent %> # The following are the most common lifecycle call backs,
12
- <%=" "* @indent %> # the following are the most common lifecycle call backs# delete any that you are not using.
20
+ <%=" "* @indent %> # the following are the most common lifecycle call backs,
21
+ <%=" "* @indent %> # delete any that you are not using.
13
22
  <%=" "* @indent %> # call backs may also reference an instance method i.e. before_mount :my_method
14
23
 
15
24
  <%=" "* @indent %> before_mount do
@@ -27,12 +36,14 @@
27
36
  <%=" "* @indent %> end
28
37
 
29
38
  <%=" "* @indent %> before_unmount do
30
- <%=" "* @indent %> # cleanup any thing (i.e. timers) before component is destroyed
39
+ <%=" "* @indent %> # cleanup any thing before component is destroyed
40
+ <%=" "* @indent %> # note timers are broadcast receivers are cleaned up
41
+ <%=" "* @indent %> # automatically
31
42
  <%=" "* @indent %> end
32
43
 
33
- <%=" "* @indent %> render do
44
+ <%- end %><%=" "* @indent %> render do
34
45
  <%=" "* @indent %> DIV do
35
- <%=" "* @indent %> "<%= (@modules+[@file_name]).join('::') %>"
46
+ <%=" "* @indent %> '<%= (@modules+[@file_name]).join('::') %>'
36
47
  <%=" "* @indent %> end
37
48
  <%=" "* @indent %> end
38
49
  <%=" "* @indent %>end
@@ -0,0 +1,10 @@
1
+ # app/hyperstack/hyper_component.rb
2
+ class <%= @component_base_class %>
3
+ # All component classes must include Hyperstack::Component
4
+ include Hyperstack::Component
5
+ # The Observable module adds state handling
6
+ include Hyperstack::State::Observable
7
+ # The following turns on the new style param accessor
8
+ # i.e. param :foo is accessed by the foo method
9
+ param_accessor_style :accessors
10
+ end
@@ -1,16 +1,16 @@
1
1
  <%- @modules.each do |module_name| %><%= " "* @indent %>module <%= module_name.camelize %><%- @indent += 1 %>
2
- <%- end %><%=" "* @indent %>class <%= @file_name %> < HyperComponent
3
- <%=" "* @indent %> include Hyperstack::State::Observer
2
+ <%- end %><%=" "* @indent %>class <%= @file_name %> < <%= @component_base_class %>
3
+ <%=" "* @indent %> include Hyperstack::Router
4
4
  <%=" "* @indent %> render do
5
5
  <%=" "* @indent %> DIV do
6
6
  <%=" "* @indent %> '<%= (@modules+[@file_name]).join('::') %>'
7
- <%=" "* @indent %> # define routes using the Route psuedo component. Examples:
7
+ <%- unless @no_help %><%=" "* @indent %> # define routes using the Route psuedo component. Examples:
8
8
  <%=" "* @indent %> # Route('/foo', mounts: Foo) : match the path beginning with /foo and mount component Foo here
9
9
  <%=" "* @indent %> # Route('/foo') { Foo(...) } : display the contents of the block
10
10
  <%=" "* @indent %> # Route('/', exact: true, mounts: Home) : match the exact path / and mount the Home component
11
11
  <%=" "* @indent %> # Route('/user/:id/name', mounts: UserName) : path segments beginning with a colon will be captured in the match param
12
12
  <%=" "* @indent %> # see the hyper-router gem documentation for more details
13
- <%=" "* @indent %> end
13
+ <%- end %><%=" "* @indent %> end
14
14
  <%=" "* @indent %> end
15
15
  <%=" "* @indent %>end
16
16
  <%- @modules.each do %><%- @indent -= 1 %><%=" "* @indent %>end
@@ -2,76 +2,49 @@ require_relative 'install_generator_base'
2
2
  module Hyperstack
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
 
5
+ class_option 'skip-hotloader', type: :boolean
5
6
  class_option 'skip-webpack', type: :boolean
6
- class_option 'skip-hot-reloader', type: :boolean
7
- class_option 'add-framework', type: :string
7
+ class_option 'skip-hyper-model', type: :boolean
8
+ class_option 'hotloader-only', type: :boolean
9
+ class_option 'webpack-only', type: :boolean
10
+ class_option 'hyper-model-only', type: :boolean
8
11
 
9
- def insure_yarn_loaded
10
- return if skip_webpack?
11
- begin
12
- yarn_version = `yarn --version`
13
- raise Errno::ENOENT if yarn_version.blank?
14
- rescue Errno::ENOENT
15
- raise Thor::Error.new("please insure the yarn command is available if using webpacker")
12
+ def add_component
13
+ if skip_adding_component?
14
+ # normally this is handled by the hyper:component
15
+ # generator, but if we are skipping it we will check it
16
+ # now.
17
+ insure_hyperstack_loader_installed
18
+ else
19
+ generate 'hyper:router App --add-route'
16
20
  end
17
21
  end
18
22
 
19
- def inject_react_file_js
20
- append_file 'app/assets/javascripts/application.js' do
21
- <<-'JS'
22
- //= require hyperstack-loader
23
- JS
23
+ def add_hotloader
24
+ return if skip_hotloader?
25
+ unless Hyperstack.imported? 'hyperstack/hotloader'
26
+ inject_into_initializer(
27
+ "Hyperstack.import 'hyperstack/hotloader', "\
28
+ 'client_only: true if Rails.env.development?'
29
+ )
24
30
  end
25
- end
26
-
27
- def create_hyperstack_directories
28
- create_file 'app/hyperstack/components/hyper_component.rb', <<-RUBY
29
- class HyperComponent
30
- include Hyperstack::Component
31
- include Hyperstack::State::Observer
32
- end
33
- RUBY
34
- create_file 'app/hyperstack/operations/.keep', ''
35
- create_file 'app/hyperstack/stores/.keep', ''
36
- create_file 'app/hyperstack/models/.keep', ''
37
- end
38
-
39
- def move_and_update_application_record
40
- unless File.exists? 'app/hyperstack/models/application_record.rb'
41
- `mv app/models/application_record.rb app/hyperstack/models/application_record.rb`
42
- create_file 'app/models/application_record.rb', <<-RUBY
43
- # app/models/application_record.rb
44
- # the presence of this file prevents rails migrations from recreating application_record.rb see https://github.com/rails/rails/issues/29407
45
-
46
- require 'models/application_record.rb'
47
- RUBY
31
+ create_file 'Procfile', <<-TEXT
32
+ web: bundle exec rails s -b 0.0.0.0
33
+ hot-loader: bundle exec hyperstack-hotloader -p 25222 -d app/hyperstack
34
+ TEXT
35
+ gem_group :development do
36
+ gem 'foreman'
48
37
  end
49
38
  end
50
39
 
51
- def create_policies_directory
52
- create_file 'app/policies/application_policy.rb', <<-RUBY
53
- # app/policies/application_policy
54
-
55
- # Policies regulate access to your public models
56
- # The following policy will open up full access (but only in development)
57
- # The policy system is very flexible and powerful. See the documentation
58
- # for complete details.
59
- class Hyperstack::ApplicationPolicy
60
- # Allow any session to connect:
61
- always_allow_connection
62
- # Send all attributes from all public models
63
- regulate_all_broadcasts { |policy| policy.send_all }
64
- # Allow all changes to public models
65
- allow_change(to: :all, on: [:create, :update, :destroy]) { true }
66
- # allow remote access to all scopes - i.e. you can count or get a list of ids
67
- # for any scope or relationship
68
- ApplicationRecord.regulate_scope :all
69
- end unless Rails.env.production?
70
- RUBY
71
- end
72
-
73
- def add_router
74
- generate "hyper:router", "App"
40
+ def insure_yarn_loaded
41
+ return if skip_webpack?
42
+ begin
43
+ yarn_version = `yarn --version`
44
+ raise Errno::ENOENT if yarn_version.blank?
45
+ rescue Errno::ENOENT
46
+ raise Thor::Error.new("please insure nodejs is installed and the yarn command is available if using webpacker")
47
+ end
75
48
  end
76
49
 
77
50
  def add_webpacker_manifests
@@ -84,20 +57,27 @@ History = require('history'); // react-router history library
84
57
  ReactRouter = require('react-router'); // react-router js library
85
58
  ReactRouterDOM = require('react-router-dom'); // react-router DOM interface
86
59
  ReactRailsUJS = require('react_ujs'); // interface to react-rails
87
- // to add additional NPM packages call run yarn package-name@version
60
+ // to add additional NPM packages run `yarn add package-name@version`
88
61
  // then add the require here.
89
62
  JAVASCRIPT
90
63
  create_file 'app/javascript/packs/client_only.js', <<-JAVASCRIPT
91
64
  //app/javascript/packs/client_only.js
92
65
  // add any requires for packages that will run client side only
93
66
  ReactDOM = require('react-dom'); // react-js client side code
94
- jQuery = require('jquery');
95
- // to add additional NPM packages call run yarn package-name@version
67
+ jQuery = require('jquery'); // remove if you don't need jQuery
68
+ // to add additional NPM packages call run yarn add package-name@version
96
69
  // then add the require here.
97
70
  JAVASCRIPT
98
71
  append_file 'config/initializers/assets.rb' do
99
72
  <<-RUBY
100
- Rails.application.config.assets.paths << Rails.root.join('public', 'packs').to_s
73
+ Rails.application.config.assets.paths << Rails.root.join('public', 'packs', 'js').to_s
74
+ RUBY
75
+ end
76
+ inject_into_file 'config/environments/test.rb', before: /^end/ do
77
+ <<-RUBY
78
+
79
+ # added by hyperstack installer
80
+ config.assets.paths << Rails.root.join('public', 'packs-test', 'js').to_s
101
81
  RUBY
102
82
  end
103
83
  end
@@ -106,74 +86,182 @@ Rails.application.config.assets.paths << Rails.root.join('public', 'packs').to_s
106
86
  return if skip_webpack?
107
87
  yarn 'react', '16'
108
88
  yarn 'react-dom', '16'
109
- yarn 'react-router', '4.2'
110
- yarn 'react-router-dom', '4.2'
111
- yarn 'history', '4.2'
112
- yarn 'react_ujs'
113
- yarn 'jquery'
89
+ yarn 'react-router', '^5.0.0'
90
+ yarn 'react-router-dom', '^5.0.0'
91
+ # yarn 'history'#, '4.2' this will be brought in by react-router
92
+ yarn 'react_ujs', '^2.5.0'
93
+ yarn 'jquery', '^3.4.1'
114
94
  end
115
95
 
116
- def add_framework
117
- framework = options['add-framework']
118
- return unless framework
119
- generate "hyperstack:install_#{framework}", "--no-build"
96
+ def cancel_react_source_import
97
+ return if skip_webpack?
98
+ inject_into_initializer(
99
+ "Hyperstack.cancel_import 'react/react-source-browser' "\
100
+ '# bring your own React and ReactRouter via Yarn/Webpacker'
101
+ )
120
102
  end
121
103
 
122
- def build_webpack
123
- system('bin/webpack')
104
+ def install_webpacker
105
+ return if skip_webpack?
106
+ gem 'webpacker'
107
+ Bundler.with_clean_env do
108
+ run 'bundle install'
109
+ end
110
+ run 'bundle exec rails webpacker:install'
124
111
  end
125
112
 
126
- # all generators should be run before the initializer due to the opal-rails opal-jquery
127
- # conflict
113
+ def create_policies_directory
114
+ return if skip_hyper_model?
115
+ policy_file = File.join('app', 'policies', 'application_policy.rb')
116
+ unless File.exist? policy_file
117
+ create_file policy_file, <<-RUBY
118
+ # #{policy_file}
128
119
 
129
- def create_initializer
130
- create_file 'config/initializers/hyperstack.rb', <<-RUBY
131
- # config/initializers/hyperstack.rb
132
- # If you are not using ActionCable, see http://hyperstack.orgs/docs/models/configuring-transport/
133
- Hyperstack.configuration do |config|
134
- config.transport = :action_cable # or :pusher or :simpler_poller or :none
135
- config.prerendering = :off # or :on
136
- #{" config.import 'jquery', client_only: true # remove this line if you don't need jquery" if skip_webpack?}
137
- config.import 'hyperstack/component/jquery', client_only: true # remove this line if you don't need jquery
138
- #{" config.import 'hyperstack/hotloader', client_only: true if Rails.env.development?" unless options['skip-hot-reloader']}
139
- end
120
+ # Policies regulate access to your public models
121
+ # The following policy will open up full access (but only in development)
122
+ # The policy system is very flexible and powerful. See the documentation
123
+ # for complete details.
124
+ class Hyperstack::ApplicationPolicy
125
+ # Allow any session to connect:
126
+ always_allow_connection
127
+ # Send all attributes from all public models
128
+ regulate_all_broadcasts { |policy| policy.send_all }
129
+ # Allow all changes to models
130
+ allow_change(to: :all, on: [:create, :update, :destroy]) { true }
131
+ # allow remote access to all scopes - i.e. you can count or get a list of ids
132
+ # for any scope or relationship
133
+ ApplicationRecord.regulate_scope :all
134
+ end unless Rails.env.production?
140
135
  RUBY
136
+ end
141
137
  end
142
138
 
143
- def inject_engine_to_routes
144
- # this needs to be the first route, thus it must be the last method executed
145
- route 'mount Hyperstack::Engine => \'/hyperstack\'' # this route should be first in the routes file so it always matches
146
- end
139
+ def move_and_update_application_record
140
+ return if skip_hyper_model?
141
+ rails_app_record_file = File.join('app', 'models', 'application_record.rb')
142
+ hyper_app_record_file = File.join('app', 'hyperstack', 'models', 'application_record.rb')
143
+ unless File.exist? hyper_app_record_file
144
+ empty_directory File.join('app', 'hyperstack', 'models')
145
+ `mv #{rails_app_record_file} #{hyper_app_record_file}`
146
+ create_file rails_app_record_file, <<-RUBY
147
+ # #{rails_app_record_file}
148
+ # the presence of this file prevents rails migrations from recreating application_record.rb
149
+ # see https://github.com/rails/rails/issues/29407
147
150
 
148
- def add_opal_hot_reloader
149
- return if options['skip-hot-reloader']
150
- create_file 'Procfile', <<-TEXT
151
- web: bundle exec rails s -b 0.0.0.0
152
- hot-loader: bundle exec hyperstack-hotloader -d app/hyperstack
153
- TEXT
154
- gem_group :development do
155
- gem 'foreman'
151
+ require 'models/application_record.rb'
152
+ RUBY
156
153
  end
157
154
  end
158
155
 
159
- def add_gems
160
- # gem 'hyper-model', Hyperstack::VERSION
161
- # gem 'hyper-router', Hyperstack::ROUTERVERSION
162
- # gem 'opal-rails', '~> 0.9.4'
163
- # gem 'opal-jquery'
164
- # gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: "master"
156
+ def add_engine_route
157
+ return if skip_hyper_model?
158
+ route 'mount Hyperstack::Engine => \'/hyperstack\' # this route should be first in the routes file so it always matches'
165
159
  end
166
160
 
167
- def install
168
- Bundler.with_clean_env do
169
- run "bundle install"
161
+ def report
162
+ say "\n\n"
163
+ unless skip_adding_component?
164
+ say '🎢 Top Level App Component successfully installed at app/hyperstack/components/app.rb 🎢', :green
165
+ end
166
+ if !new_rails_app?
167
+ say '🎢 Top Level App Component skipped, you can manually generate it later 🎢', :green
168
+ end
169
+ unless skip_webpack?
170
+ say '📦 Webpack integrated with Hyperstack. '\
171
+ 'Add javascript assets to app/javascript/packs/client_only.js and /client_and_server.js 📦', :green
172
+ end
173
+ unless skip_hyper_model?
174
+ say '👩‍✈️ Basic development policy defined. See app/policies/application_policy.rb 👨🏽‍✈️', :green
175
+ say '💽 HyperModel installed. Move any Active Record models to the app/hyperstack/models to access them from the client 📀', :green
176
+ end
177
+ if File.exist?(init = File.join('config', 'initializers', 'hyperstack.rb'))
178
+ say "☑️ Check #{init} for other configuration options. ☑️", :green
170
179
  end
180
+ unless skip_hotloader?
181
+ say '🚒 Hyperstack Hotloader installed - use bundle exec foreman start and visit localhost:5000 🚒', :green
182
+ end
183
+
184
+ say "\n\n"
171
185
  end
172
186
 
173
187
  private
174
188
 
189
+ def skip_adding_component?
190
+ options['hotloader-only'] || options['webpack-only'] || options['hyper-model-only'] || !new_rails_app?
191
+ end
192
+
193
+ def skip_hotloader?
194
+ options['skip-hotloader'] || options['webpack-only'] || options['hyper-model-only']
195
+ end
196
+
175
197
  def skip_webpack?
176
- options['skip-webpack'] || !defined?(Webpacker)
198
+ options['hotloader-only'] || options['skip-webpack'] || options['hyper-model-only']
199
+ end
200
+
201
+ def skip_hyper_model?
202
+ options['hotloader-only'] || options['webpack-only'] || options['skip-hyper-model']
203
+ end
204
+
205
+ def new_rails_app?
206
+ # check to see if there are any routes set up and remember it, cause we might add a route in the process
207
+ @new_rails_app ||= begin
208
+ route_file = File.join('config', 'routes.rb')
209
+ count = File.foreach(route_file).inject(0) do |c, line|
210
+ line = line.strip
211
+ next c if line.empty?
212
+ next c if line.start_with?('#')
213
+ next c if line.start_with?('mount')
214
+ c + 1
215
+ end
216
+ count <= 2
217
+ end
218
+ end
219
+
220
+ def inject_into_initializer(s)
221
+ file_name = File.join('config', 'initializers', 'hyperstack.rb')
222
+ if File.exist?(file_name)
223
+ prepend_to_file(file_name) { "#{s}\n" }
224
+ else
225
+ create_file file_name, <<-RUBY
226
+ #{s}
227
+ # set the component base class
228
+
229
+ Hyperstack.component_base_class = 'HyperComponent' # i.e. 'ApplicationComponent'
230
+
231
+ # prerendering is default :off, you should wait until your
232
+ # application is relatively well debugged before turning on.
233
+
234
+ Hyperstack.prerendering = :off # or :on
235
+
236
+ # transport controls how push (websocket) communications are
237
+ # implemented. The default is :action_cable.
238
+ # Other possibilities are :pusher (see www.pusher.com) or
239
+ # :simple_poller which is sometimes handy during system debug.
240
+
241
+ Hyperstack.transport = :action_cable # or :none, :pusher, :simple_poller
242
+
243
+ # add this line if you need jQuery AND ARE NOT USING WEBPACK
244
+ # Hyperstack.import 'hyperstack/component/jquery', client_only: true
245
+
246
+ # change definition of on_error to control how errors such as validation
247
+ # exceptions are reported on the server
248
+ module Hyperstack
249
+ def self.on_error(operation, err, params, formatted_error_message)
250
+ ::Rails.logger.debug(
251
+ "\#{formatted_error_message}\\n\\n" +
252
+ Pastel.new.red(
253
+ 'To further investigate you may want to add a debugging '\\
254
+ 'breakpoint to the on_error method in config/initializers/hyperstack.rb'
255
+ )
256
+ )
257
+ end
258
+ end if Rails.env.development?
259
+ RUBY
260
+ end
261
+ # whenever we modify the initializer its best to empty the cache, BUT
262
+ # we only need to it once per generator execution
263
+ run 'rm -rf tmp/cache' unless @cache_emptied_already
264
+ @cache_emptied_already = true
177
265
  end
178
266
  end
179
267
  end
@@ -6,14 +6,90 @@ module Rails
6
6
 
7
7
  protected
8
8
 
9
+ def create_component_file(template)
10
+ clear_cache
11
+ insure_hyperstack_loader_installed
12
+ insure_base_component_class_exists
13
+ @no_help = options.key?('no-help')
14
+ self.components.each do |component|
15
+ component_array = component.split('::')
16
+ @modules = component_array[0..-2]
17
+ @file_name = component_array.last
18
+ @indent = 0
19
+ template template,
20
+ File.join('app', 'hyperstack', 'components',
21
+ *@modules.map(&:downcase),
22
+ "#{@file_name.underscore}.rb")
23
+ end
24
+ add_route
25
+ end
26
+
27
+
28
+ def clear_cache
29
+ run 'rm -rf tmp/cache' unless Dir.exist?(File.join('app', 'hyperstack'))
30
+ end
31
+
32
+ def insure_hyperstack_loader_installed
33
+ application_js = File.join(
34
+ 'app', 'assets', 'javascripts', 'application.js'
35
+ )
36
+ require_tree = %r{//=\s+require_tree\s+}
37
+ hyperstack_loader = %r{//=\s+require\s+hyperstack-loader\s+}
38
+ unless File.foreach(application_js).any? { |l| l =~ hyperstack_loader }
39
+ if File.foreach(application_js).any? { |l| l =~ require_tree }
40
+ inject_into_file 'app/assets/javascripts/application.js', before: require_tree do
41
+ "//= require hyperstack-loader\n"
42
+ end
43
+ else
44
+ puts " ***********************************************************\n"\
45
+ " * Could not add `//= require hyperstack-loader` directive *\n"\
46
+ " * to the app/assets/application.js file. *\n"\
47
+ " * Normally this directive is added just before the *\n"\
48
+ " * `//= require_tree .` directive at the end of the file, *\n"\
49
+ " * but no require_tree directive was found. You need to *\n"\
50
+ " * manually add `//= require hyperstack-loader` to the *\n"\
51
+ " * app/assets/application.js file. *\n"\
52
+ " ***********************************************************\n"
53
+ end
54
+ end
55
+ end
56
+
57
+ def insure_base_component_class_exists
58
+ @component_base_class = options['base-class'] || Hyperstack.component_base_class
59
+ file_name = File.join(
60
+ 'app', 'hyperstack', 'components', "#{@component_base_class.underscore}.rb"
61
+ )
62
+ template 'hyper_component_template.rb', file_name unless File.exist? file_name
63
+ end
64
+
9
65
  def add_to_manifest(manifest, &block)
10
- if File.exists? "app/javascript/packs/#{manifest}"
66
+ if File.exist? "app/javascript/packs/#{manifest}"
11
67
  append_file "app/javascript/packs/#{manifest}", &block
12
68
  else
13
69
  create_file "app/javascript/packs/#{manifest}", &block
14
70
  end
15
71
  end
16
72
 
73
+ def add_route
74
+ return unless options['add-route']
75
+ if self.components.count > 1
76
+ puts " ***********************************************************\n"\
77
+ " * The add-route option ignored because more than one *\n"\
78
+ " * component is being generated. *\n"\
79
+ " ***********************************************************\n"
80
+ return
81
+ end
82
+ action_name = (@modules+[@file_name.underscore]).join('__')
83
+ path = options['add-route'] == 'add-route' ? '/(*others)' : options['add-route']
84
+ routing_code = "get '#{path}', to: 'hyperstack##{action_name}'\n"
85
+ log :route, routing_code
86
+ [/mount\s+Hyperstack::Engine[^\n]+\n/m, /\.routes\.draw do\s*\n/m].each do |sentinel|
87
+ in_root do
88
+ inject_into_file 'config/routes.rb', routing_code.indent(2), after: sentinel, verbose: false, force: false
89
+ end
90
+ end
91
+ end
92
+
17
93
  def yarn(package, version = nil)
18
94
  return if system("yarn add #{package}#{'@' + version if version}")
19
95
  raise Thor::Error.new("yarn failed to install #{package} with version #{version}")
@@ -0,0 +1,229 @@
1
+ require_relative '../hyperstack/install_generator_base'
2
+ module Install
3
+ class HyperstackGenerator < Rails::Generators::Base
4
+
5
+ class_option 'skip-webpack', type: :boolean
6
+ class_option 'skip-hot-reloader', type: :boolean
7
+ class_option 'add-framework', type: :string
8
+
9
+ def insure_yarn_loaded
10
+ return if skip_webpack?
11
+ begin
12
+ yarn_version = `yarn --version`
13
+ raise Errno::ENOENT if yarn_version.blank?
14
+ rescue Errno::ENOENT
15
+ raise Thor::Error.new("please insure the yarn command is available if using webpacker")
16
+ end
17
+ end
18
+
19
+ APPJS = 'app/assets/javascripts/application.js'
20
+
21
+ def inject_hyperstack_loader_js
22
+ unless File.foreach(APPJS).any?{ |l| l['//= require hyperstack-loader'] }
23
+ inject_into_file 'app/assets/javascripts/application.js', before: %r{//= require_tree .} do
24
+ "//= require hyperstack-loader\n"
25
+ end
26
+ end
27
+ end
28
+
29
+ def create_hyperstack_files_and_directories
30
+ create_file 'app/hyperstack/components/hyper_component.rb', <<-RUBY
31
+ class HyperComponent
32
+ include Hyperstack::Component
33
+ include Hyperstack::State::Observable
34
+ param_accessor_style :accessors
35
+ end
36
+ RUBY
37
+ create_file 'app/hyperstack/operations/.keep', ''
38
+ create_file 'app/hyperstack/stores/.keep', ''
39
+ create_file 'app/hyperstack/models/.keep', ''
40
+ end
41
+
42
+ def move_and_update_application_record
43
+ unless File.exists? 'app/hyperstack/models/application_record.rb'
44
+ `mv app/models/application_record.rb app/hyperstack/models/application_record.rb`
45
+ create_file 'app/models/application_record.rb', <<-RUBY
46
+ # app/models/application_record.rb
47
+ # the presence of this file prevents rails migrations from recreating application_record.rb see https://github.com/rails/rails/issues/29407
48
+
49
+ require 'models/application_record.rb'
50
+ RUBY
51
+ end
52
+ end
53
+
54
+ def create_policies_directory
55
+ create_file 'app/policies/application_policy.rb', <<-RUBY
56
+ # app/policies/application_policy.rb
57
+
58
+ # Policies regulate access to your public models
59
+ # The following policy will open up full access (but only in development)
60
+ # The policy system is very flexible and powerful. See the documentation
61
+ # for complete details.
62
+ class Hyperstack::ApplicationPolicy
63
+ # Allow any session to connect:
64
+ always_allow_connection
65
+ # Send all attributes from all public models
66
+ regulate_all_broadcasts { |policy| policy.send_all }
67
+ # Allow all changes to models
68
+ allow_change(to: :all, on: [:create, :update, :destroy]) { true }
69
+ # allow remote access to all scopes - i.e. you can count or get a list of ids
70
+ # for any scope or relationship
71
+ ApplicationRecord.regulate_scope :all
72
+ end unless Rails.env.production?
73
+ RUBY
74
+ end
75
+
76
+ def add_router
77
+ generate "hyper:router", "App"
78
+ route "get '/(*other)', to: 'hyperstack#app'"
79
+ end
80
+ if false
81
+ def add_webpackin
82
+ run 'yarn add react'
83
+ run 'yarn add react-dom'
84
+ run 'yarn add react-router'
85
+ create_file 'app/javascript/packs/hyperstack.js', <<-CODE
86
+ // Import all the modules
87
+ import React from 'react';
88
+ import ReactDOM from 'react-dom';
89
+
90
+ // for opal/hyperstack modules to find React and others they must explicitly be saved
91
+ // to the global space, otherwise webpack will encapsulate them locally here
92
+ global.React = React;
93
+ global.ReactDOM = ReactDOM;
94
+ CODE
95
+ inject_into_file 'app/views/layouts/application.html.erb', before: %r{<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>} do
96
+ <<-CODE
97
+ <%= javascript_pack_tag 'hyperstack' %>
98
+ CODE
99
+ end
100
+ gem 'webpacker'
101
+ end
102
+
103
+
104
+ else
105
+ def add_webpacker_manifests
106
+ return if skip_webpack?
107
+ create_file 'app/javascript/packs/client_and_server.js', <<-JAVASCRIPT
108
+ //app/javascript/packs/client_and_server.js
109
+ // these packages will be loaded both during prerendering and on the client
110
+ React = require('react'); // react-js library
111
+ History = require('history'); // react-router history library
112
+ ReactRouter = require('react-router'); // react-router js library
113
+ ReactRouterDOM = require('react-router-dom'); // react-router DOM interface
114
+ ReactRailsUJS = require('react_ujs'); // interface to react-rails
115
+ // to add additional NPM packages call run yarn add package-name@version
116
+ // then add the require here.
117
+ JAVASCRIPT
118
+ create_file 'app/javascript/packs/client_only.js', <<-JAVASCRIPT
119
+ //app/javascript/packs/client_only.js
120
+ // add any requires for packages that will run client side only
121
+ ReactDOM = require('react-dom'); // react-js client side code
122
+ jQuery = require('jquery');
123
+ // to add additional NPM packages call run yarn add package-name@version
124
+ // then add the require here.
125
+ JAVASCRIPT
126
+ append_file 'config/initializers/assets.rb' do
127
+ <<-RUBY
128
+ Rails.application.config.assets.paths << Rails.root.join('public', 'packs', 'js').to_s
129
+ RUBY
130
+ end
131
+ inject_into_file 'config/environments/test.rb', before: /^end/ do
132
+ <<-RUBY
133
+
134
+ # added by hyperstack installer
135
+ config.assets.paths << Rails.root.join('public', 'packs-test', 'js').to_s
136
+ RUBY
137
+ end
138
+
139
+ end
140
+
141
+ def add_webpacks
142
+ return if skip_webpack?
143
+ yarn 'react', '16'
144
+ yarn 'react-dom', '16'
145
+ yarn 'react-router', '^5.0.0'
146
+ yarn 'react-router-dom', '^5.0.0'
147
+ # yarn 'history'#, '4.2' this will be brought in by react-router
148
+ yarn 'react_ujs', '^2.5.0'
149
+ yarn 'jquery', '^3.4.1'
150
+ end
151
+
152
+ def add_webpacker_gem
153
+ gem 'webpacker'
154
+ end
155
+
156
+ def add_framework
157
+ framework = options['add-framework']
158
+ return unless framework
159
+ generate "hyperstack:install_#{framework}", "--no-build"
160
+ end
161
+
162
+ # def build_webpack
163
+ # system('bin/webpack')
164
+ # end
165
+ end
166
+ # all generators should be run before the initializer due to the opal-rails opal-jquery
167
+ # conflict
168
+
169
+ def create_initializer
170
+ create_file 'config/initializers/hyperstack.rb', <<-CODE
171
+ # config/initializers/hyperstack.rb
172
+ # If you are not using ActionCable, see http://hyperstack.orgs/docs/models/configuring-transport/
173
+ Hyperstack.configuration do |config|
174
+ config.transport = :action_cable
175
+ config.prerendering = :off # or :on
176
+ config.cancel_import 'react/react-source-browser' # bring your own React and ReactRouter via Yarn/Webpacker
177
+ config.import 'hyperstack/component/jquery', client_only: true # remove this line if you don't need jquery
178
+ config.import 'hyperstack/hotloader', client_only: true if Rails.env.development?
179
+ end
180
+
181
+ # useful for debugging
182
+ module Hyperstack
183
+ def self.on_error(operation, err, params, formatted_error_message)
184
+ ::Rails.logger.debug(
185
+ "\#{formatted_error_message}\\n\\n" +
186
+ Pastel.new.red(
187
+ 'To further investigate you may want to add a debugging '\\
188
+ 'breakpoint to the on_error method in config/initializers/hyperstack.rb'
189
+ )
190
+ )
191
+ end
192
+ end if Rails.env.development?
193
+ CODE
194
+ end
195
+
196
+ def inject_engine_to_routes
197
+ # this needs to be the first route, thus it must be the last method executed
198
+ route 'mount Hyperstack::Engine => \'/hyperstack\'' # this route should be first in the routes file so it always matches
199
+ end
200
+
201
+ def add_opal_hot_reloader
202
+ return if options['skip-hot-reloader']
203
+ create_file 'Procfile', <<-TEXT
204
+ web: bundle exec rails s -b 0.0.0.0
205
+ hot-loader: bundle exec hyperstack-hotloader -p 25222 -d app/hyperstack
206
+ TEXT
207
+ gem_group :development do
208
+ gem 'foreman'
209
+ end
210
+ end
211
+
212
+ def add_gems
213
+
214
+ end
215
+
216
+ def install
217
+ Bundler.with_clean_env do
218
+ run "bundle install"
219
+ end
220
+ run 'bundle exec rails webpacker:install'
221
+ end
222
+
223
+ private
224
+
225
+ def skip_webpack?
226
+ options['skip-webpack'] #|| !defined?(Webpacker)
227
+ end
228
+ end
229
+ end
@@ -0,0 +1,76 @@
1
+ require 'rails/generators'
2
+
3
+ module Rails
4
+ module Generators
5
+ class Base < Thor::Group
6
+
7
+ protected
8
+
9
+ def clear_cache
10
+ run 'rm -rf tmp/cache' unless Dir.exists?(File.join('app', 'hyperstack'))
11
+ end
12
+
13
+ def insure_hyperstack_loader_installed
14
+ application_js = File.join(
15
+ 'app', 'assets', 'javascripts', 'application.js'
16
+ )
17
+ require_tree = %r{//=\s+require_tree\s+}
18
+ hyperstack_loader = %r{//=\s+require\s+hyperstack-loader\s+}
19
+ unless File.foreach(application_js).any? { |l| l =~ hyperstack_loader }
20
+ if File.foreach(application_js).any? { |l| l =~ require_tree }
21
+ inject_into_file 'app/assets/javascripts/application.js', before: require_tree do
22
+ "//= require hyperstack-loader\n"
23
+ end
24
+ else
25
+ puts " ***********************************************************\n"\
26
+ " * Could not add `//= require hyperstack-loader` directive *\n"\
27
+ " * to the app/assets/application.js file. *\n"\
28
+ " * Normally this directive is added just before the *\n"\
29
+ " * `//= require_tree .` directive at the end of the file, *\n"\
30
+ " * but no require_tree directive was found. You need to *\n"\
31
+ " * manually add `//= require hyperstack-loader` to the *\n"\
32
+ " * app/assets/application.js file. *\n"\
33
+ " ***********************************************************\n"
34
+ end
35
+ end
36
+ end
37
+
38
+
39
+ def insure_base_component_class_exists
40
+ @component_base_class = options['base-class']
41
+ file_name = File.join(
42
+ 'app', 'hyperstack', 'components', "#{@component_base_class.underscore}.rb"
43
+ )
44
+ template 'hyper_component_template.rb', file_name unless File.exists? file_name
45
+ end
46
+
47
+ def add_to_manifest(manifest, &block)
48
+ if File.exists? "app/javascript/packs/#{manifest}"
49
+ append_file "app/javascript/packs/#{manifest}", &block
50
+ else
51
+ create_file "app/javascript/packs/#{manifest}", &block
52
+ end
53
+ end
54
+
55
+ def add_route
56
+ return unless options['add-route']
57
+ if self.components.count > 1
58
+ puts " ***********************************************************\n"\
59
+ " * The add-route option ignored because more than one *\n"\
60
+ " * component is being generated. *\n"\
61
+ " ***********************************************************\n"
62
+ return
63
+ end
64
+ action_name = (@modules+[@file_name.underscore]).join('__')
65
+ path = options['add-route'] == 'add-route' ? '/(*others)' : options['add-route']
66
+ route "get '#{path}', to: 'hyperstack##{action_name}'"
67
+ end
68
+
69
+
70
+ def yarn(package, version = nil)
71
+ return if system("yarn add #{package}#{'@' + version if version}")
72
+ raise Thor::Error.new("yarn failed to install #{package} with version #{version}")
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,3 +1,3 @@
1
1
  module Hyperstack
2
- ROUTERVERSION = VERSION = '1.0.alpha1.4'
2
+ ROUTERVERSION = VERSION = '1.0.alpha1.5'
3
3
  end
@@ -14,6 +14,7 @@ Hyperstack.import 'hyper-model'
14
14
  Hyperstack.import 'hyper-state'
15
15
 
16
16
  require 'generators/hyperstack/install_generator'
17
+ require 'generators/hyper/generator_base'
17
18
  require 'generators/hyper/component_generator'
18
19
  require 'generators/hyper/router_generator'
19
20
  begin
@@ -26,3 +27,11 @@ require 'react-rails'
26
27
  require 'opal-browser'
27
28
  require 'mini_racer'
28
29
  require 'hyperstack/version'
30
+
31
+ class RailsHyperstack < Rails::Railtie
32
+ rake_tasks do
33
+ Dir[File.join(File.dirname(__FILE__),'tasks/hyperstack/*.rake')].each { |f| puts "loading #{f}"; load f }
34
+ end
35
+ end
36
+
37
+ Hyperstack.define_setting :component_base_class, 'HyperComponent'
@@ -0,0 +1,32 @@
1
+ # install_template_path = File.expand_path("../../install/template.rb", __dir__).freeze
2
+ bin_path = ENV["BUNDLE_BIN"] || "./bin"
3
+ require 'optparse'
4
+
5
+ namespace :hyperstack do
6
+ desc "Install Hyperstack in this application"
7
+ task :install do
8
+ exec "#{RbConfig.ruby} #{bin_path}/rails g hyperstack:install"
9
+ end
10
+ namespace :install do
11
+ task :default do
12
+ end
13
+ task "hotloader" do
14
+ exec "#{RbConfig.ruby} #{bin_path}/rails g hyperstack:install --hotloader-only"
15
+ end
16
+ task "webpack" do
17
+ exec "#{RbConfig.ruby} #{bin_path}/rails g hyperstack:install --webpack-only"
18
+ end
19
+ task "hyper-model" do
20
+ exec "#{RbConfig.ruby} #{bin_path}/rails g hyperstack:install --hyper-model-only"
21
+ end
22
+ task "skip-hotloader" do
23
+ exec "#{RbConfig.ruby} #{bin_path}/rails g hyperstack:install --skip-hotloader"
24
+ end
25
+ task "skip-webpack" do
26
+ exec "#{RbConfig.ruby} #{bin_path}/rails g hyperstack:install --skip-webpack"
27
+ end
28
+ task "skip-hyper-model" do
29
+ exec "#{RbConfig.ruby} #{bin_path}/rails g hyperstack:install --skip-hyper-model"
30
+ end
31
+ end
32
+ end
@@ -18,6 +18,41 @@ Gem::Specification.new do |spec|
18
18
  # }
19
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(tasks)/}) }
20
20
  spec.require_paths = ['lib']
21
+ spec.post_install_message = %q{
22
+ *******************************************************************************
23
+
24
+ Welcome to Hyperstack!
25
+
26
+ For a quick start simply add a component using one of the generators:
27
+
28
+ >> bundle exec rails generate hyper:component CompName --add-route="/test/(*others)"
29
+ # Add a new component named CompName and route to it with /test/
30
+
31
+ >> bundle exec rails generate hyper:router CompName --add-route="/test/(*others)"
32
+ # Add a top level router named CompName and route to it
33
+
34
+ The generators will insure you have the minimal additions to your system for the
35
+ new component to run. And note: --add-route is optional.
36
+
37
+ For a complete install run the hyperstack install task:
38
+
39
+ >> bundle exec rails hyperstack:install
40
+
41
+ This will add everything you need including the hotloader, webpack integration,
42
+ hyper-model (active record model client synchronization) and a top level
43
+ component to get you started.
44
+
45
+ You can control how much of the stack gets installed as well:
46
+
47
+ >> bundle exec rails hyperstack:install:webpack # just add webpack
48
+ >> bundle exec rails hyperstack:install:skip-webpack # all but webpack
49
+ >> bundle exec rails hyperstack:install:hyper-model # just add hyper-model
50
+ >> bundle exec rails hyperstack:install:skip-hyper-model # all but hyper-model
51
+ >> bundle exec rails hyperstack:install:hotloader # just add the hotloader
52
+ >> bundle exec rails hyperstack:install:skip-hotloader # skip the hotloader
53
+
54
+ *******************************************************************************
55
+ }
21
56
 
22
57
  spec.add_dependency 'hyper-model', Hyperstack::VERSION
23
58
  spec.add_dependency 'hyper-router', Hyperstack::ROUTERVERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-hyperstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.alpha1.4
4
+ version: 1.0.alpha1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loic Boutet
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-02-16 00:00:00.000000000 Z
14
+ date: 2019-06-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: hyper-model
@@ -19,42 +19,42 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.alpha1.4
22
+ version: 1.0.alpha1.5
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.alpha1.4
29
+ version: 1.0.alpha1.5
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: hyper-router
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 1.0.alpha1.4
36
+ version: 1.0.alpha1.5
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
- version: 1.0.alpha1.4
43
+ version: 1.0.alpha1.5
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: hyperstack-config
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - '='
49
49
  - !ruby/object:Gem::Version
50
- version: 1.0.alpha1.4
50
+ version: 1.0.alpha1.5
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - '='
56
56
  - !ruby/object:Gem::Version
57
- version: 1.0.alpha1.4
57
+ version: 1.0.alpha1.5
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: opal-rails
60
60
  requirement: !ruby/object:Gem::Requirement
@@ -185,14 +185,14 @@ dependencies:
185
185
  requirements:
186
186
  - - '='
187
187
  - !ruby/object:Gem::Version
188
- version: 1.0.alpha1.4
188
+ version: 1.0.alpha1.5
189
189
  type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - '='
194
194
  - !ruby/object:Gem::Version
195
- version: 1.0.alpha1.4
195
+ version: 1.0.alpha1.5
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: pry
198
198
  requirement: !ruby/object:Gem::Requirement
@@ -389,15 +389,20 @@ files:
389
389
  - Gemfile
390
390
  - Rakefile
391
391
  - lib/generators/hyper/component_generator.rb
392
+ - lib/generators/hyper/generator_base.rb
392
393
  - lib/generators/hyper/router_generator.rb
393
394
  - lib/generators/hyper/templates/component_template.rb
395
+ - lib/generators/hyper/templates/hyper_component_template.rb
394
396
  - lib/generators/hyper/templates/router_template.rb
395
397
  - lib/generators/hyperstack/install_bootstrap_generator.rb
396
398
  - lib/generators/hyperstack/install_generator.rb
397
399
  - lib/generators/hyperstack/install_generator_base.rb
398
400
  - lib/generators/hyperstack/install_mui_generator.rb
401
+ - lib/generators/install/hyperstack_generator.rb
402
+ - lib/generators/install/hyperstack_generator_base.rb
399
403
  - lib/hyperstack/version.rb
400
404
  - lib/rails-hyperstack.rb
405
+ - lib/tasks/hyperstack/install.rake
401
406
  - rails-hyperstack.gemspec
402
407
  - spec/rails_hyperstack_spec.rb
403
408
  - spec/spec_helper.rb
@@ -405,7 +410,41 @@ homepage: http://hyperstack.org
405
410
  licenses:
406
411
  - MIT
407
412
  metadata: {}
408
- post_install_message:
413
+ post_install_message: |2
414
+
415
+ *******************************************************************************
416
+
417
+ Welcome to Hyperstack!
418
+
419
+ For a quick start simply add a component using one of the generators:
420
+
421
+ >> bundle exec rails generate hyper:component CompName --add-route="/test/(*others)"
422
+ # Add a new component named CompName and route to it with /test/
423
+
424
+ >> bundle exec rails generate hyper:router CompName --add-route="/test/(*others)"
425
+ # Add a top level router named CompName and route to it
426
+
427
+ The generators will insure you have the minimal additions to your system for the
428
+ new component to run. And note: --add-route is optional.
429
+
430
+ For a complete install run the hyperstack install task:
431
+
432
+ >> bundle exec rails hyperstack:install
433
+
434
+ This will add everything you need including the hotloader, webpack integration,
435
+ hyper-model (active record model client synchronization) and a top level
436
+ component to get you started.
437
+
438
+ You can control how much of the stack gets installed as well:
439
+
440
+ >> bundle exec rails hyperstack:install:webpack # just add webpack
441
+ >> bundle exec rails hyperstack:install:skip-webpack # all but webpack
442
+ >> bundle exec rails hyperstack:install:hyper-model # just add hyper-model
443
+ >> bundle exec rails hyperstack:install:skip-hyper-model # all but hyper-model
444
+ >> bundle exec rails hyperstack:install:hotloader # just add the hotloader
445
+ >> bundle exec rails hyperstack:install:skip-hotloader # skip the hotloader
446
+
447
+ *******************************************************************************
409
448
  rdoc_options: []
410
449
  require_paths:
411
450
  - lib
@@ -420,7 +459,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
420
459
  - !ruby/object:Gem::Version
421
460
  version: 1.3.1
422
461
  requirements: []
423
- rubygems_version: 3.0.2
462
+ rubygems_version: 3.0.4
424
463
  signing_key:
425
464
  specification_version: 4
426
465
  summary: Hyperstack for Rails with generators