isomorfeus-installer 1.0.0.delta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +0 -0
  3. data/bin/isomorfeus +137 -0
  4. data/isomorfeus-installer.gemspec +19 -0
  5. data/lib/isomorfeus/installer.rb +234 -0
  6. data/lib/isomorfeus/installer/asset_bundlers/opal_webpack_loader.rb +103 -0
  7. data/lib/isomorfeus/installer/databases/arangodb.rb +11 -0
  8. data/lib/isomorfeus/installer/databases/mysql.rb +11 -0
  9. data/lib/isomorfeus/installer/databases/neo4j.rb +11 -0
  10. data/lib/isomorfeus/installer/databases/none.rb +11 -0
  11. data/lib/isomorfeus/installer/databases/postgresql.rb +11 -0
  12. data/lib/isomorfeus/installer/frameworks/cuba.rb +26 -0
  13. data/lib/isomorfeus/installer/frameworks/rails.rb +78 -0
  14. data/lib/isomorfeus/installer/frameworks/roda.rb +26 -0
  15. data/lib/isomorfeus/installer/frameworks/sinatra.rb +26 -0
  16. data/lib/isomorfeus/installer/spectre.rb +0 -0
  17. data/lib/isomorfeus/installer/templates/Gemfile.erb +15 -0
  18. data/lib/isomorfeus/installer/templates/Procfile.erb +2 -0
  19. data/lib/isomorfeus/installer/templates/application.js.erb +29 -0
  20. data/lib/isomorfeus/installer/templates/cuba/config_ru.erb +48 -0
  21. data/lib/isomorfeus/installer/templates/isomorfeus_loader.rb.erb +8 -0
  22. data/lib/isomorfeus/installer/templates/my_app.rb.erb +17 -0
  23. data/lib/isomorfeus/installer/templates/my_component.rb.erb +12 -0
  24. data/lib/isomorfeus/installer/templates/owl/development.js.erb +145 -0
  25. data/lib/isomorfeus/installer/templates/owl/production.js.erb +93 -0
  26. data/lib/isomorfeus/installer/templates/owl/test.js.erb +0 -0
  27. data/lib/isomorfeus/installer/templates/package.json.erb +21 -0
  28. data/lib/isomorfeus/installer/templates/rails/application.html.erb.head +6 -0
  29. data/lib/isomorfeus/installer/templates/rails/application.html.erb.tail +6 -0
  30. data/lib/isomorfeus/installer/templates/rails/application_controller.rb +5 -0
  31. data/lib/isomorfeus/installer/templates/rails/application_helper.rb.erb +3 -0
  32. data/lib/isomorfeus/installer/templates/rails/assets.rb.erb +1 -0
  33. data/lib/isomorfeus/installer/templates/rails/basic-react.rb +453 -0
  34. data/lib/isomorfeus/installer/templates/rails/index.html +1 -0
  35. data/lib/isomorfeus/installer/templates/rails/routes.rb +5 -0
  36. data/lib/isomorfeus/installer/templates/roda/config_ru.erb +39 -0
  37. data/lib/isomorfeus/installer/templates/sinatra/config_ru.erb +38 -0
  38. data/lib/isomorfeus/installer/transport.rb +0 -0
  39. data/lib/isomorfeus/installer/transport_store.rb +0 -0
  40. data/lib/isomorfeus/installer/transports/actioncable.rb +11 -0
  41. data/readme.md +69 -0
  42. metadata +97 -0
@@ -0,0 +1,93 @@
1
+ const path = require('path');
2
+ const OwlResolver = require('opal-webpack-loader/resolver');
3
+ const CompressionPlugin = require("compression-webpack-plugin"); // for gzipping the packs
4
+ const ManifestPlugin = require('webpack-manifest-plugin'); // for generating the manifest
5
+
6
+ module.exports = {
7
+ parallelism: 8,
8
+ context: path.resolve(__dirname, '<%= isomorfeus_path %>'),
9
+ mode: "production",
10
+ optimization: {
11
+ minimize: true // minimize
12
+ },
13
+ performance: {
14
+ maxAssetSize: 20000000, // isomorfeus is some code
15
+ maxEntrypointSize: 20000000
16
+ },
17
+ entry: {
18
+ application: [path.resolve(__dirname, '<%= entrypoint_path %>')],
19
+ },
20
+ plugins: [
21
+ new CompressionPlugin({ test: /.js/ }), // gzip compress
22
+ new ManifestPlugin() // generate manifest
23
+ ],
24
+ output: {
25
+ filename: '[name]-[chunkhash].js', // include fingerprint in file name, so browsers get the latest
26
+ path: path.resolve(__dirname, '<%= asset_output_path %>'),
27
+ publicPath: '/assets/'
28
+ },
29
+ resolve: {
30
+ plugins: [
31
+ // resolve ruby files
32
+ new OwlResolver('resolve', 'resolved')
33
+ ]
34
+ },
35
+ module: {
36
+ rules: [
37
+ {
38
+ test: /.scss$/,
39
+ use: [
40
+ {
41
+ loader: "style-loader",
42
+ options: {
43
+ hmr: false
44
+ }
45
+ },
46
+ {
47
+ loader: "css-loader"
48
+ },
49
+ {
50
+ loader: "sass-loader",
51
+ options: {
52
+ includePath: [
53
+ path.resolve(__dirname, '<%= stylesheets_path %>')
54
+ ]
55
+ }
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ test: /.css$/,
61
+ use: [
62
+ 'style-loader',
63
+ 'css-loader'
64
+ ]
65
+ },
66
+ {
67
+ test: /.(png|svg|jpg|gif)$/,
68
+ use: [
69
+ 'file-loader'
70
+ ]
71
+ },
72
+ {
73
+ test: /.(woff|woff2|eot|ttf|otf)$/,
74
+ use: [
75
+ 'file-loader'
76
+ ]
77
+ },
78
+ {
79
+ // opal-webpack-loader will compile and include ruby files in the pack
80
+ test: /.(rb|js.rb)$/,
81
+ use: [
82
+ {
83
+ loader: 'opal-webpack-loader',
84
+ options: {
85
+ sourceMap: false
86
+ }
87
+ }
88
+ ]
89
+ }
90
+ ]
91
+ }
92
+ };
93
+
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "<%= application_name %>",
3
+ "private": true,
4
+ "dependencies": {
5
+ <%= npm_packages %>
6
+ "react": "16.6",
7
+ "react-dom": "16.6",
8
+ "react-hot-loader": "^4.3.11",
9
+ "react-router": "^4.3.1",
10
+ "react-router-dom": "^4.3.1",
11
+ "redux": "^4.0.1"
12
+ },
13
+ <%= scripts %>
14
+ "devDependencies": {
15
+ "compression-webpack-plugin": "^2.0.0",
16
+ "webpack": "^4.27.0",
17
+ "webpack-cli": "^3.1.1",
18
+ "webpack-dev-server": "^3.1.10",
19
+ "webpack-manifest-plugin": "^2.0.4"
20
+ }
21
+ }
@@ -0,0 +1,6 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>IntestRails</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
@@ -0,0 +1,6 @@
1
+ </head>
2
+
3
+ <body>
4
+ <%= yield %>
5
+ </body>
6
+ </html>
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ def index
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module ApplicationHelper
2
+ <%= asset_bundler_includes %>
3
+ end
@@ -0,0 +1 @@
1
+ <%= asset_bundler_config %>
@@ -0,0 +1,453 @@
1
+ # Isomorfeus Basic Template
2
+
3
+ ## Commit base rails for we have a full commit history
4
+
5
+ git :init
6
+ git add: "."
7
+ git commit: "-m 'Initial commit: Rails base'"
8
+
9
+ ## Add the gems
10
+
11
+ gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export'
12
+ gem 'opal-autoloader', '~> 0.0.2'
13
+ gem 'isomorfeus-react', github: 'isomorfeus/isomorfeus-framework', branch: 'ulysses', glob: 'ruby/isomorfeus-react/*.gemspec'
14
+
15
+ # ----------------------------------- Create the folders
16
+
17
+ run 'mkdir app/isomorfeus'
18
+ run 'mkdir app/isomorfeus/components'
19
+
20
+ # ----------------------------------- Add .keep files
21
+
22
+ file 'app/isomorfeus/components/.keep', ''
23
+
24
+ # ----------------------------------- Create the Isomorfeus loader file
25
+
26
+ file 'app/isomorfeus/isomorfeus_webpack_loader.rb', <<-CODE
27
+ require 'opal'
28
+ require 'opal-autoloader'
29
+ require 'isomorfeus-react'
30
+
31
+ require_tree 'components'
32
+ CODE
33
+
34
+ # ----------------------------------- Create isomorfeus.js
35
+
36
+ file 'app/javascript/app.js', <<-CODE
37
+ import React from 'react';
38
+ import ReactDOM from 'react-dom';
39
+ import * as History from 'history';
40
+ import * as ReactRouter from 'react-router';
41
+ import * as ReactRouterDOM from 'react-router-dom';
42
+ import ActionCable from 'actioncable';
43
+
44
+ global.React = React;
45
+ global.ReactDOM = ReactDOM;
46
+ global.History = History;
47
+ global.ReactRouter = ReactRouter;
48
+ global.ReactRouterDOM = ReactRouterDOM;
49
+ global.ActionCable = ActionCable;
50
+
51
+ import init_app from 'isomorfeus_webpack_loader.rb';
52
+
53
+ init_app();
54
+ Opal.load('isomorfeus_webpack_loader');
55
+ if (module.hot) {
56
+ module.hot.accept('./app.js', function () {
57
+ console.log('Accepting the updated Isomorfeus module!');
58
+ })
59
+ }
60
+ CODE
61
+
62
+ # ----------------------------------- Create webpack config development.js
63
+
64
+ file 'config/webpack/development.js', <<-CODE
65
+ // require requirements used below
66
+ const path = require('path');
67
+ const webpack = require('webpack');
68
+ const chokidar = require('chokidar'); // for watching app/view
69
+ const WebSocket = require('ws');
70
+ const OwlResolver = require('opal-webpack-loader/resolver'); // to resolve ruby files
71
+
72
+ module.exports = {
73
+ parallelism: 8,
74
+ context: path.resolve(__dirname, '../..'),
75
+ mode: "development",
76
+ optimization: {
77
+ minimize: false // dont minimize in development, to speed up hot reloads
78
+ },
79
+ performance: {
80
+ maxAssetSize: 20000000, // isomorfeus is some code
81
+ maxEntrypointSize: 20000000
82
+ },
83
+ // use this or others below, disable for faster hot reloads
84
+ devtool: 'source-map', // this works well, good compromise between accuracy and performance
85
+ // devtool: 'cheap-eval-source-map', // less accurate
86
+ // devtool: 'inline-source-map', // slowest
87
+ // devtool: 'inline-cheap-source-map',
88
+ entry: {
89
+ app: ['./app/javascript/app.js'], // entrypoint for isomorfeus
90
+ },
91
+ output: {
92
+ // webpack-serve keeps the output in memory
93
+ filename: '[name]_development.js',
94
+ path: path.resolve(__dirname, '../../public/packs'),
95
+ publicPath: 'http://localhost:3035/packs/'
96
+ },
97
+ resolve: {
98
+ plugins: [
99
+ // this makes it possible for webpack to find ruby files
100
+ new OwlResolver('resolve', 'resolved')
101
+ ]
102
+ },
103
+ plugins: [
104
+ // both for hot reloading
105
+ new webpack.NamedModulesPlugin()
106
+ ],
107
+ module: {
108
+ rules: [
109
+ {
110
+ // loader for .scss files
111
+ // test means "test for for file endings"
112
+ test: /\.scss$/,
113
+ use: [
114
+ {
115
+ loader: "style-loader",
116
+ options: {
117
+ hmr: true
118
+ }
119
+ },
120
+ {
121
+ loader: "css-loader",
122
+ options: {
123
+ sourceMap: true, // set to false to speed up hot reloads
124
+ minimize: false // set to false to speed up hot reloads
125
+ }
126
+ },
127
+ {
128
+ loader: "sass-loader",
129
+ options: {
130
+ includePaths: [path.resolve(__dirname, '../../app/assets/stylesheets')],
131
+ sourceMap: true // set to false to speed up hot reloads
132
+ }
133
+ }
134
+ ]
135
+ },
136
+ {
137
+ // loader for .css files
138
+ test: /\.css$/,
139
+ use: [
140
+ {
141
+ loader: "style-loader",
142
+ options: {
143
+ hmr: true
144
+ }
145
+ },
146
+ {
147
+ loader: "css-loader",
148
+ options: {
149
+ sourceMap: true, // set to false to speed up hot reloads
150
+ minimize: false // set to false to speed up hot reloads
151
+ }
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ test: /\.(png|svg|jpg|gif)$/,
157
+ use: [
158
+ 'file-loader'
159
+ ]
160
+ },
161
+ {
162
+ test: /\.(woff|woff2|eot|ttf|otf)$/,
163
+ use: [
164
+ 'file-loader'
165
+ ]
166
+ },
167
+ {
168
+ // opal-webpack-loader will compile and include ruby files in the pack
169
+ test: /\.(rb|js.rb)$/,
170
+ use: [
171
+ 'opal-webpack-loader'
172
+ ]
173
+ }
174
+ ]
175
+ },
176
+ // configuration for webpack serve
177
+ serve: {
178
+ devMiddleware: {
179
+ publicPath: '/packs/',
180
+ headers: {
181
+ 'Access-Control-Allow-Origin': '*'
182
+ },
183
+ watchOptions: {
184
+
185
+ }
186
+ },
187
+ hotClient: {
188
+ host: 'localhost',
189
+ port: 8081,
190
+ allEntries: true,
191
+ hmr: true
192
+ },
193
+ host: "localhost",
194
+ port: 3035,
195
+ logLevel: 'debug',
196
+ content: path.resolve(__dirname, '../../public/packs'),
197
+ clipboard: false,
198
+ open: false,
199
+ on: {
200
+ "listening": function (server) {
201
+ const socket = new WebSocket('ws://localhost:8081');
202
+ const watchPath = path.resolve(__dirname, '../../app/views');
203
+ const options = {};
204
+ const watcher = chokidar.watch(watchPath, options);
205
+
206
+ watcher.on('change', () => {
207
+ const data = {
208
+ type: 'broadcast',
209
+ data: {
210
+ type: 'window-reload',
211
+ data: {},
212
+ },
213
+ };
214
+
215
+ socket.send(JSON.stringify(data));
216
+ });
217
+
218
+ server.server.on('close', () => {
219
+ watcher.close();
220
+ });
221
+ }
222
+ }
223
+ }
224
+ };
225
+
226
+ CODE
227
+
228
+ # ----------------------------------- Create webpack config production.js
229
+
230
+ file 'config/webpack/production.js', <<-CODE
231
+ const path = require('path');
232
+ const OwlResolver = require('opal-webpack-loader/resolver');
233
+ const CompressionPlugin = require("compression-webpack-plugin"); // for gzipping the packs
234
+ const ManifestPlugin = require('webpack-manifest-plugin'); // for generating the manifest
235
+
236
+ module.exports = {
237
+ parallelism: 8,
238
+ context: path.resolve(__dirname, '../..'),
239
+ mode: "production",
240
+ optimization: {
241
+ minimize: true // minimize
242
+ },
243
+ performance: {
244
+ maxAssetSize: 20000000, // isomorfeus is some code
245
+ maxEntrypointSize: 20000000
246
+ },
247
+ entry: {
248
+ app: './app/javascript/app.js',
249
+ },
250
+ plugins: [
251
+ new CompressionPlugin({ test: /\.js/ }), // gzip compress
252
+ new ManifestPlugin() // generate manifest
253
+ ],
254
+ output: {
255
+ filename: '[name]-[chunkhash].js', // include fingerprint in file name, so browsers get the latest
256
+ path: path.resolve(__dirname, '../../public/packs'),
257
+ publicPath: '/packs/'
258
+ },
259
+ resolve: {
260
+ plugins: [
261
+ // resolve ruby files
262
+ new OwlResolver('resolve', 'resolved')
263
+ ]
264
+ },
265
+ module: {
266
+ rules: [
267
+ {
268
+ test: /\.scss$/,
269
+ use: [
270
+ {
271
+ loader: "style-loader",
272
+ options: {
273
+ hmr: false
274
+ }
275
+ },
276
+ {
277
+ loader: "css-loader"
278
+ },
279
+ {
280
+ loader: "sass-loader",
281
+ options: {
282
+ includePath: [
283
+ path.resolve(__dirname, '../../app/assets/stylesheets')
284
+ ]
285
+ }
286
+ }
287
+ ]
288
+ },
289
+ {
290
+ test: /\.css$/,
291
+ use: [
292
+ 'style-loader',
293
+ 'css-loader'
294
+ ]
295
+ },
296
+ {
297
+ test: /\.(png|svg|jpg|gif)$/,
298
+ use: [
299
+ 'file-loader'
300
+ ]
301
+ },
302
+ {
303
+ test: /\.(woff|woff2|eot|ttf|otf)$/,
304
+ use: [
305
+ 'file-loader'
306
+ ]
307
+ },
308
+ {
309
+ // compile and load ruby files
310
+ test: /\.(rb|js.rb)$/,
311
+ use: [
312
+ 'opal-webpack-loader'
313
+ ]
314
+ }
315
+ ]
316
+ }
317
+ };
318
+
319
+ CODE
320
+
321
+ # create config for test.js
322
+ file 'config/webpack/test.js', <<-CODE
323
+ const path = require('path');
324
+ const webpack = require('webpack');
325
+ const OwlResolver = require('opal-webpack-loader/resolver');
326
+
327
+ module.exports = {
328
+ parallelism: 8,
329
+ context: path.resolve(__dirname, '../..'),
330
+ mode: "test",
331
+ optimization: {
332
+ minimize: false
333
+ },
334
+ performance: {
335
+ maxAssetSize: 20000000,
336
+ maxEntrypointSize: 20000000
337
+ },
338
+ entry: {
339
+ app: './app/javascript/app.js',
340
+ },
341
+ output: {
342
+ filename: '[name]_test.js',
343
+ path: path.resolve(__dirname, '../../public/packs'),
344
+ publicPath: '/packs/'
345
+ },
346
+ resolve: {
347
+ plugins: [
348
+ new OwlResolver('resolve', 'resolved')
349
+ ]
350
+ },
351
+ module: {
352
+ rules: [
353
+ {
354
+ test: /\.scss$/,
355
+ use: [
356
+ { loader: "style-loader" },
357
+ { loader: "css-loader" },
358
+ {
359
+ loader: "sass-loader",
360
+ options: {
361
+ includePaths: [path.resolve(__dirname, '../../app/assets/stylesheets')]
362
+ }
363
+ }
364
+ ]
365
+ },
366
+ {
367
+ test: /\.css$/,
368
+ use: [
369
+ 'style-loader',
370
+ 'css-loader'
371
+ ]
372
+ },
373
+ {
374
+ test: /\.(png|svg|jpg|gif)$/,
375
+ use: [
376
+ 'file-loader'
377
+ ]
378
+ },
379
+ {
380
+ test: /\.(woff|woff2|eot|ttf|otf)$/,
381
+ use: [
382
+ 'file-loader'
383
+ ]
384
+ },
385
+ {
386
+ test: /\.(rb|js.rb)$/,
387
+ use: [
388
+ 'opal-webpack-loader'
389
+ ]
390
+ }
391
+ ]
392
+ }
393
+ };
394
+
395
+
396
+ CODE
397
+
398
+ # ----------------------------------- Scripts for package.json
399
+
400
+ inject_into_file 'package.json', after: %r{"dependencies": {}} do
401
+ <<-CODE
402
+ ,
403
+ "scripts": {
404
+ "test": "bundle exec opal-webpack-compile-server kill; bundle exec opal-webpack-compile-server && webpack --config=config/webpack/test.js; bundle exec opal-webpack-compile-server kill",
405
+ "start": "bundle exec opal-webpack-compile-server kill; bundle exec opal-webpack-compile-server && bundle exec webpack-serve --config ./config/webpack/development.js; bundle exec opal-webpack-compile-server kill",
406
+ "build": "bundle exec opal-webpack-compile-server kill; bundle exec opal-webpack-compile-server && webpack --config=config/webpack/production.js; bundle exec opal-webpack-compile-server kill"
407
+ }
408
+ CODE
409
+ end
410
+
411
+ # ----------------------------------- Add NPM modules
412
+
413
+ run 'yarn add react'
414
+ run 'yarn add react-dom'
415
+ run 'yarn add react-router'
416
+ run 'yarn add react-router-dom'
417
+ run 'yarn add opal-webpack-loader'
418
+ run 'yarn add -D webpack-serve'
419
+ run 'yarn add webpack-cli'
420
+ run 'yarn add -D compression-webpack-plugin'
421
+ run 'yarn add -D webpack-manifest-plugin'
422
+
423
+ ## ----------------------------------- Add to application_helper
424
+
425
+ inject_into_file 'app/helpers/application_helper.rb', after: 'module ApplicationHelper' do
426
+ <<-CODE
427
+
428
+ include OpalWebpackLoader::RailsViewHelper
429
+ CODE
430
+ end
431
+
432
+ # ----------------------------------- View template
433
+
434
+ inject_into_file 'app/views/layouts/application.html.erb', after: %r{<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>} do
435
+ <<-CODE
436
+
437
+ <%= owl_script_tag '/packs/app.js' %>
438
+ CODE
439
+ end
440
+
441
+ # ----------------------------------- Procfile
442
+
443
+ file 'Procfile', <<-CODE
444
+ app : bundle exec puma
445
+ webpack_serve: yarn run start
446
+ CODE
447
+
448
+ # ----------------------------------- Commit Isomorfeus setup
449
+
450
+ after_bundle do
451
+ git add: "."
452
+ git commit: "-m 'Isomorfeus config complete'"
453
+ end