|
9 | 9 | # ----------------------------------- Add the gems |
10 | 10 |
|
11 | 11 | gem 'webpacker' |
12 | | -gem 'hyperloop', github: 'hyperstack-org/hyperstack', branch: 'edge', glob: 'ruby/*/*.gemspec' |
13 | | -gem 'opal_hot_reloader', github: 'hyperstack-org/opal-hot-reloader' |
| 12 | +gem 'rails-hyperstack', github: 'hyperstack-org/hyperstack', branch: 'edge', glob: 'ruby/*/*.gemspec' |
14 | 13 |
|
15 | 14 | gem_group :development do |
16 | 15 | gem 'foreman' |
17 | 16 | end |
18 | 17 |
|
19 | 18 | # ----------------------------------- Create the folders |
20 | 19 |
|
21 | | -run 'mkdir app/hyperloop' |
22 | | -run 'mkdir app/hyperloop/components' |
23 | | -run 'mkdir app/hyperloop/stores' |
24 | | -run 'mkdir app/hyperloop/models' |
25 | | -run 'mkdir app/hyperloop/operations' |
| 20 | +run 'mkdir app/hyperstack' |
| 21 | +run 'mkdir app/hyperstack/components' |
| 22 | +run 'mkdir app/hyperstack/stores' |
| 23 | +run 'mkdir app/hyperstack/models' |
| 24 | +run 'mkdir app/hyperstack/operations' |
26 | 25 |
|
27 | 26 | # ----------------------------------- Add .keep files |
28 | 27 |
|
29 | | -run 'touch app/hyperloop/components/.keep' |
30 | | -run 'touch app/hyperloop/stores/.keep' |
31 | | -run 'touch app/hyperloop/models/.keep' |
32 | | -run 'touch app/hyperloop/operations/.keep' |
| 28 | +run 'touch app/hyperstack/stores/.keep' |
| 29 | +run 'touch app/hyperstack/models/.keep' |
| 30 | +run 'touch app/hyperstack/operations/.keep' |
33 | 31 |
|
34 | | -# ----------------------------------- Create the Hyperloop config |
| 32 | +# ----------------------------------- Create the HyperCompnent base class |
35 | 33 |
|
36 | | -file 'config/initializers/hyperloop.rb', <<-CODE |
37 | | -Hyperloop.configuration do |config| |
| 34 | +file 'app/hyperstack/components/hyper_component.rb', <<-CODE |
| 35 | +class HyperComponent |
| 36 | + include Hyperstack::Component |
| 37 | + include Hyperstack::State::Observer |
| 38 | +end |
| 39 | +CODE |
| 40 | + |
| 41 | +# ----------------------------------- Create the Hyperstack config |
| 42 | + |
| 43 | +file 'config/initializers/hyperstack.rb', <<-CODE |
| 44 | +# config/initializers/hyperstack.rb |
| 45 | +# If you are not using ActionCable, see http://hyperstack.orgs/docs/models/configuring-transport/ |
| 46 | +Hyperstack.configuration do |config| |
38 | 47 | # config.transport = :action_cable |
39 | | - config.import 'reactrb/auto-import' |
40 | | - config.import 'opal_hot_reloader' |
| 48 | + config.prerendering = :off # or :on |
41 | 49 | config.cancel_import 'react/react-source-browser' # bring your own React and ReactRouter via Yarn/Webpacker |
| 50 | + config.import 'hyperstack/component/jquery', client_only: true # remove this line if you don't need jquery |
| 51 | + config.import 'hyperstack/hotloader', client_only: true if Rails.env.development? |
42 | 52 | end |
43 | 53 | CODE |
44 | 54 |
|
|
55 | 65 | import React from 'react'; |
56 | 66 | import ReactDOM from 'react-dom'; |
57 | 67 |
|
58 | | -// for opal/hyperloop modules to find React and others they must explicitly be saved |
| 68 | +// for opal/hyperstack modules to find React and others they must explicitly be saved |
59 | 69 | // to the global space, otherwise webpack will encapsulate them locally here |
60 | 70 | global.React = React; |
61 | 71 | global.ReactDOM = ReactDOM; |
|
75 | 85 | <<-CODE |
76 | 86 | //= require jquery |
77 | 87 | //= require jquery_ujs |
78 | | -//= require hyperloop-loader |
| 88 | +//= require hyperstack-loader |
79 | 89 | CODE |
80 | 90 | end |
81 | 91 |
|
82 | 92 | # ----------------------------------- Procfile |
83 | 93 |
|
84 | 94 | file 'Procfile', <<-CODE |
85 | 95 | web: bundle exec puma |
86 | | -hot: opal-hot-reloader -p 25222 -d app/hyperloop/ |
87 | | -CODE |
88 | | - |
89 | | -# ----------------------------------- OpalHotReloader client |
90 | | - |
91 | | -file 'app/hyperloop/components/hot_loader.rb', <<-CODE |
92 | | -require 'opal_hot_reloader' |
93 | | -OpalHotReloader.listen(25222, false) |
| 96 | +hot: hyperstack-hotloader -p 25222 -d app/hyperstack/ |
94 | 97 | CODE |
95 | 98 |
|
96 | 99 | # ----------------------------------- Mount point |
97 | 100 |
|
98 | | -route "mount Hyperloop::Engine => '/hyperloop'" |
| 101 | +route "mount Hyperstack::Engine => '/hyperstack'" |
99 | 102 |
|
100 | 103 | # ----------------------------------- Hello World |
101 | 104 |
|
102 | | -route "root 'hyperloop#HelloWorld'" |
103 | | -file 'app/hyperloop/components/hello_world.rb', <<-CODE |
104 | | -class HelloWorld < Hyperloop::Component |
| 105 | +route "root 'hyperstack#HelloWorld'" |
| 106 | +file 'app/hyperstack/components/hello_world.rb', <<-CODE |
| 107 | +class HelloWorld < HyperComponent |
105 | 108 | render do |
106 | 109 | H1 { "Hello world from Hyperstack edge!" } |
107 | 110 | end |
108 | 111 | end |
109 | 112 | CODE |
110 | 113 |
|
111 | | -# ----------------------------------- Commit Hyperloop setup |
| 114 | +# ----------------------------------- Commit Hyperstack setup |
112 | 115 |
|
113 | 116 | after_bundle do |
114 | 117 | run 'bundle exec rails webpacker:install' |
|
0 commit comments