rails-hyperstack 1.0.alpha1.2 → 1.0.alpha1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07a67d4c25a49e2881d995b54e390c96a0cdd0e154e43d6487db9036a8533c57
4
- data.tar.gz: 5f2b819d7856336bac745113a3cc4748187f2c90cad5eb55cdf671ed0fc6a850
3
+ metadata.gz: 7acc1e5d18ec60370e1eab5f0de65d969a26f771e3d2fb7ef2216001db1b6ea2
4
+ data.tar.gz: 7df5554317659537d441f80b667657d517988a9243e388164ddebcef9ec50022
5
5
  SHA512:
6
- metadata.gz: f3b1a4b2ebd4adddfc44b36efef0ee173d8d67f29fc23531ab05b9f46771cd8c845a00a2697a2fbb3f8c93d7a96693ce9814be0fcd2c6baf72b6d06084409428
7
- data.tar.gz: ca0c71c308f702096ac0d6578940a27b8168cf05c19358392af7089e668e739f8becb58edc4b03b371109b50f5efc7b65b745e1b617d2a530f9ec78a979880b8
6
+ metadata.gz: 87e26686b53e2f81dd691891e2ca9ba3f65f5b932e327fec2f735461379fec80e1237da208945979fb692f9ab3e314bebe3d58be47a00b4dfe708355a7621d81
7
+ data.tar.gz: 16c44081e8751b66f25748f205240933570e00b2700be20b2d3ea64d3b4a0d438ce0c29aaf05a5e48afaa1213fd4ea3aeba051262a9d67e0a40237e12a4ebc1a
data/.gitignore CHANGED
@@ -11,6 +11,7 @@ capybara-*.html
11
11
  **.orig
12
12
  rerun.txt
13
13
  pickle-email-*.html
14
+ TestApp/
14
15
 
15
16
  # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
16
17
  config/initializers/secret_token.rb
@@ -46,3 +47,12 @@ bower.json
46
47
 
47
48
  # ignore Idea
48
49
  .idea
50
+
51
+ # ignore Gemfile.locks https://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
52
+ /spec/test_app/Gemfile.lock
53
+ /Gemfile.lock
54
+
55
+ node_modules
56
+ package.json
57
+ spec/test_app
58
+ yarn.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.2
data/Gemfile CHANGED
@@ -6,5 +6,6 @@ gem 'hyper-operation', path: '../hyper-operation'
6
6
  gem 'hyper-model', path: '../hyper-model'
7
7
  gem 'hyper-router', path: '../hyper-router'
8
8
  gem 'hyper-spec', path: '../hyper-spec'
9
- gem 'rails', '~> 5.2'
9
+ gem 'webpacker' # TODO: figure out why these two are necessary!
10
+ gem 'turbolinks'
10
11
  gemspec
data/Rakefile CHANGED
@@ -1,25 +1,35 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require 'pry'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
7
  namespace :spec do
7
8
  task :prepare do
9
+ rails_version = `bundle info rails`.match(/\* rails \((.+)\)/)[1]
10
+ opal_version = `bundle info opal`.match(/\* opal \((.+)\)/)[1]
8
11
  Dir.chdir('spec') do
9
12
  sh('rm -rf test_app')
10
- sh('bundle exec rails new test_app')
11
- Dir.chdir('test_app') do
12
- sh('bundle exec rails g hyperstack:install')
13
- sh('mv Gemfile _Gemfile_')
14
- sh('bundle exec rails generate model Sample name:string description:text')
15
- sh('mv app/models/sample.rb app/hyperstack/models/sample.rb')
16
- sh('bundle exec rake db:migrate')
17
- sh('bundle exec rails dev:cache')
13
+ Bundler.with_unbundled_env do
14
+ sh("rails _#{rails_version}_ new test_app -T")
15
+ end
16
+ Bundler.with_unbundled_env do
17
+ Dir.chdir('test_app') do
18
+ sh('cat ../gems.rb >> Gemfile')
19
+ sh("echo 'gem \"opal\", \"#{opal_version}\"' >> Gemfile")
20
+ sh("bundle update")
21
+ sh('spring stop')
22
+ sh('bundle exec rails g hyperstack:install')
23
+ sh('bundle exec rails generate model Sample name:string description:text')
24
+ sh('mv app/models/sample.rb app/hyperstack/models/sample.rb')
25
+ sh("cat ../server_side_sample.rb >> app/models/sample.rb")
26
+ sh('bundle exec rake db:migrate')
27
+ sh('RAILS_ENV=test bundle exec rake db:setup')
28
+ # sh('bundle exec rails dev:cache') # not tested yet...
29
+ end
18
30
  end
19
31
  end
20
32
  end
21
33
  end
22
34
 
23
- task :default do
24
-
25
- end
35
+ task :default => :spec
@@ -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 and 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,178 +2,178 @@ 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
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")
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
11
+
12
+ def add_hotloader
13
+ return if skip_hotloader?
14
+ unless Hyperstack.imported? 'hyperstack/hotloader'
15
+ inject_into_initializer(
16
+ "Hyperstack.import 'hyperstack/hotloader', "\
17
+ 'client_only: true if Rails.env.development?'
18
+ )
19
+ end
20
+ create_file 'Procfile', <<-TEXT
21
+ web: bundle exec rails s -b 0.0.0.0
22
+ hot-loader: bundle exec hyperstack-hotloader -p 25222 -d app/hyperstack
23
+ TEXT
24
+ gem_group :development do
25
+ gem 'foreman'
16
26
  end
17
27
  end
18
28
 
19
- def inject_react_file_js
20
- append_file 'app/assets/javascripts/application.js' do
21
- <<-'JS'
22
- //= require hyperstack-loader
23
- JS
29
+ def install_webpack
30
+ return super unless skip_webpack?
31
+
32
+ inject_into_initializer(
33
+ "Hyperstack.import 'react/react-source-browser' "\
34
+ "# bring in hyperstack's copy of react, comment this out "\
35
+ "if you bring it in from webpacker\n"
36
+ )
37
+ end
38
+
39
+ def add_component
40
+ # add_component AFTER webpack so component generator webpack check works
41
+ if skip_adding_component?
42
+ # normally this is handled by the hyper:component
43
+ # generator, but if we are skipping it we will check it
44
+ # now.
45
+ insure_hyperstack_loader_installed
46
+ check_javascript_link_directory
47
+ else
48
+ generate 'hyper:router App --add-route'
24
49
  end
25
50
  end
26
51
 
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
52
+ def create_policies_directory
53
+ return if skip_hyper_model?
54
+ policy_file = Rails.root.join('app', 'policies', 'hyperstack', 'application_policy.rb')
55
+ unless File.exist? policy_file
56
+ create_file policy_file, <<-RUBY
57
+ # #{policy_file}
58
+
59
+ # Policies regulate access to your public models
60
+ # The following policy will open up full access (but only in development)
61
+ # The policy system is very flexible and powerful. See the documentation
62
+ # for complete details.
63
+ module Hyperstack
64
+ class ApplicationPolicy
65
+ # Allow any session to connect:
66
+ always_allow_connection
67
+ # Send all attributes from all public models
68
+ regulate_all_broadcasts { |policy| policy.send_all }
69
+ # Allow all changes to models
70
+ allow_change(to: :all, on: [:create, :update, :destroy]) { true }
71
+ end unless Rails.env.production?
32
72
  end
33
73
  RUBY
34
- create_file 'app/hyperstack/operations/.keep', ''
35
- create_file 'app/hyperstack/stores/.keep', ''
36
- create_file 'app/hyperstack/models/.keep', ''
74
+ end
37
75
  end
38
76
 
39
77
  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
78
+ return if skip_hyper_model?
79
+ rails_app_record_file = Rails.root.join('app', 'models', 'application_record.rb')
80
+ hyper_app_record_file = Rails.root.join('app', 'hyperstack', 'models', 'application_record.rb')
81
+ unless File.exist? hyper_app_record_file
82
+ empty_directory Rails.root.join('app', 'hyperstack', 'models')
83
+ `mv #{rails_app_record_file} #{hyper_app_record_file}`
84
+ inject_into_file hyper_app_record_file, before: /^end/, verbose: false do
85
+ " # allow remote access to all scopes - i.e. you can count or get a list of ids\n"\
86
+ " # for any scope or relationship\n"\
87
+ " ApplicationRecord.regulate_scope :all unless Hyperstack.env.production?\n"
88
+ end
89
+
90
+ # create_file rails_app_record_file, <<-RUBY
91
+ # # #{rails_app_record_file}
92
+ # # the presence of this file prevents rails migrations from recreating application_record.rb
93
+ # # see https://github.com/rails/rails/issues/29407
94
+ #
95
+ # require 'models/application_record.rb'
96
+ # RUBY
48
97
  end
49
98
  end
50
99
 
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?
100
+ def turn_on_transport
101
+ inject_into_initializer <<-RUBY
102
+
103
+ # transport controls how push (websocket) communications are
104
+ # implemented. The default is :none.
105
+ # Other possibilities are :action_cable, :pusher (see www.pusher.com)
106
+ # or :simple_poller which is sometimes handy during system debug.
107
+
108
+ Hyperstack.transport = :action_cable # :pusher, :simple_poller or :none
109
+
70
110
  RUBY
71
111
  end
72
112
 
73
- def add_router
74
- generate "hyper:router", "App"
113
+ def add_engine_route
114
+ return if skip_hyper_model?
115
+ route 'mount Hyperstack::Engine => \'/hyperstack\' # this route should be first in the routes file so it always matches'
75
116
  end
76
117
 
77
- def add_webpacker_manifests
78
- return if skip_webpack?
79
- create_file 'app/javascript/packs/client_and_server.js', <<-JAVASCRIPT
80
- //app/javascript/packs/client_and_server.js
81
- // these packages will be loaded both during prerendering and on the client
82
- React = require('react'); // react-js library
83
- History = require('history'); // react-router history library
84
- ReactRouter = require('react-router'); // react-router js library
85
- ReactRouterDOM = require('react-router-dom'); // react-router DOM interface
86
- ReactRailsUJS = require('react_ujs'); // interface to react-rails
87
- // to add additional NPM packages call run yarn package-name@version
88
- // then add the require here.
89
- JAVASCRIPT
90
- create_file 'app/javascript/packs/client_only.js', <<-JAVASCRIPT
91
- //app/javascript/packs/client_only.js
92
- // add any requires for packages that will run client side only
93
- 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
96
- // then add the require here.
97
- JAVASCRIPT
98
- append_file 'config/initializers/assets.rb' do
99
- <<-RUBY
100
- Rails.application.config.assets.paths << Rails.root.join('public', 'packs').to_s
101
- RUBY
118
+ def report
119
+ say "\n\n"
120
+ unless skip_adding_component?
121
+ say '🎢 Top Level App Component successfully installed at app/hyperstack/components/app.rb 🎢', :green
122
+ end
123
+ if !new_rails_app?
124
+ say '🎢 Top Level App Component skipped, you can manually generate it later 🎢', :green
125
+ end
126
+ unless skip_webpack?
127
+ say '📦 Webpack integrated with Hyperstack. '\
128
+ 'Add javascript assets to app/javascript/packs/client_only.js and /client_and_server.js 📦', :green
129
+ end
130
+ unless skip_hyper_model?
131
+ say '👩‍✈️ Basic development policy defined. See app/policies/application_policy.rb 👨🏽‍✈️', :green
132
+ say '💽 HyperModel installed. Move any Active Record models to the app/hyperstack/models to access them from the client 📀', :green
133
+ end
134
+ if File.exist?(init = Rails.root.join('config', 'initializers', 'hyperstack.rb'))
135
+ say "☑️ Check #{init} for other configuration options. ☑️", :green
136
+ end
137
+ unless skip_hotloader?
138
+ say '🚒 Hyperstack Hotloader installed - use bundle exec foreman start and visit localhost:5000 🚒', :green
102
139
  end
103
- end
104
140
 
105
- def add_webpacks
106
- return if skip_webpack?
107
- yarn 'react', '16'
108
- 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'
114
- end
141
+ say "\n\n"
115
142
 
116
- def add_framework
117
- framework = options['add-framework']
118
- return unless framework
119
- generate "hyperstack:install_#{framework}", "--no-build"
143
+ warnings.each { |warning| say "#{warning}", :yellow }
120
144
  end
121
145
 
122
- def build_webpack
123
- system('bin/webpack')
124
- end
146
+ private
125
147
 
126
- # all generators should be run before the initializer due to the opal-rails opal-jquery
127
- # conflict
128
-
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
140
- RUBY
148
+ def skip_adding_component?
149
+ options['hotloader-only'] || options['webpack-only'] || options['hyper-model-only'] || !new_rails_app?
141
150
  end
142
151
 
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
152
+ def skip_hotloader?
153
+ options['skip-hotloader'] || options['webpack-only'] || options['hyper-model-only']
146
154
  end
147
155
 
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'
156
- end
156
+ def skip_webpack?
157
+ options['hotloader-only'] || options['skip-webpack'] || options['hyper-model-only']
157
158
  end
158
159
 
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"
160
+ def skip_hyper_model?
161
+ options['hotloader-only'] || options['webpack-only'] || options['skip-hyper-model']
165
162
  end
166
163
 
167
- def install
168
- Bundler.with_clean_env do
169
- run "bundle install"
164
+ def new_rails_app?
165
+ # check to see if there are any routes set up and remember it, cause we might add a route in the process
166
+ @new_rails_app ||= begin
167
+ route_file = Rails.root.join('config', 'routes.rb')
168
+ count = File.foreach(route_file).inject(0) do |c, line|
169
+ line = line.strip
170
+ next c if line.empty?
171
+ next c if line.start_with?('#')
172
+ next c if line.start_with?('mount')
173
+ c + 1
174
+ end
175
+ count <= 2
170
176
  end
171
177
  end
172
-
173
- private
174
-
175
- def skip_webpack?
176
- options['skip-webpack'] || !defined?(Webpacker)
177
- end
178
178
  end
179
179
  end