isomorfeus-installer 1.0.0.delta1
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 +7 -0
- data/Gemfile +0 -0
- data/bin/isomorfeus +137 -0
- data/isomorfeus-installer.gemspec +19 -0
- data/lib/isomorfeus/installer.rb +234 -0
- data/lib/isomorfeus/installer/asset_bundlers/opal_webpack_loader.rb +103 -0
- data/lib/isomorfeus/installer/databases/arangodb.rb +11 -0
- data/lib/isomorfeus/installer/databases/mysql.rb +11 -0
- data/lib/isomorfeus/installer/databases/neo4j.rb +11 -0
- data/lib/isomorfeus/installer/databases/none.rb +11 -0
- data/lib/isomorfeus/installer/databases/postgresql.rb +11 -0
- data/lib/isomorfeus/installer/frameworks/cuba.rb +26 -0
- data/lib/isomorfeus/installer/frameworks/rails.rb +78 -0
- data/lib/isomorfeus/installer/frameworks/roda.rb +26 -0
- data/lib/isomorfeus/installer/frameworks/sinatra.rb +26 -0
- data/lib/isomorfeus/installer/spectre.rb +0 -0
- data/lib/isomorfeus/installer/templates/Gemfile.erb +15 -0
- data/lib/isomorfeus/installer/templates/Procfile.erb +2 -0
- data/lib/isomorfeus/installer/templates/application.js.erb +29 -0
- data/lib/isomorfeus/installer/templates/cuba/config_ru.erb +48 -0
- data/lib/isomorfeus/installer/templates/isomorfeus_loader.rb.erb +8 -0
- data/lib/isomorfeus/installer/templates/my_app.rb.erb +17 -0
- data/lib/isomorfeus/installer/templates/my_component.rb.erb +12 -0
- data/lib/isomorfeus/installer/templates/owl/development.js.erb +145 -0
- data/lib/isomorfeus/installer/templates/owl/production.js.erb +93 -0
- data/lib/isomorfeus/installer/templates/owl/test.js.erb +0 -0
- data/lib/isomorfeus/installer/templates/package.json.erb +21 -0
- data/lib/isomorfeus/installer/templates/rails/application.html.erb.head +6 -0
- data/lib/isomorfeus/installer/templates/rails/application.html.erb.tail +6 -0
- data/lib/isomorfeus/installer/templates/rails/application_controller.rb +5 -0
- data/lib/isomorfeus/installer/templates/rails/application_helper.rb.erb +3 -0
- data/lib/isomorfeus/installer/templates/rails/assets.rb.erb +1 -0
- data/lib/isomorfeus/installer/templates/rails/basic-react.rb +453 -0
- data/lib/isomorfeus/installer/templates/rails/index.html +1 -0
- data/lib/isomorfeus/installer/templates/rails/routes.rb +5 -0
- data/lib/isomorfeus/installer/templates/roda/config_ru.erb +39 -0
- data/lib/isomorfeus/installer/templates/sinatra/config_ru.erb +38 -0
- data/lib/isomorfeus/installer/transport.rb +0 -0
- data/lib/isomorfeus/installer/transport_store.rb +0 -0
- data/lib/isomorfeus/installer/transports/actioncable.rb +11 -0
- data/readme.md +69 -0
- metadata +97 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Installer
|
3
|
+
module Frameworks
|
4
|
+
module Cuba
|
5
|
+
def self.start_command
|
6
|
+
'bundle exec puma'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.install(root)
|
10
|
+
data_hash = { requires: Isomorfeus::Installer.create_requires,
|
11
|
+
script_tag: Isomorfeus::Installer.asset_bundler&.script_tag(Isomorfeus::Installer.entrypoint),
|
12
|
+
asset_bundler_includes: Isomorfeus::Installer.asset_bundler&.asset_bundler_includes,
|
13
|
+
asset_bundler_config: Isomorfeus::Installer.asset_bundler&.asset_bundler_config }
|
14
|
+
|
15
|
+
Isomorfeus::Installer.create_file_from_template(File.join('cuba', 'config_ru.erb'), 'config.ru', data_hash)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Isomorfeus::Installer.add_framework('cuba', {
|
23
|
+
gems: [ { name: 'cuba', version: '~> 3.9.2' }, { name: 'puma', version: '~> 3.12.0' } ],
|
24
|
+
installer: Isomorfeus::Installer::Frameworks::Cuba,
|
25
|
+
structure: :iso
|
26
|
+
})
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Installer
|
3
|
+
module Frameworks
|
4
|
+
module Rails
|
5
|
+
VERSION = '~> 5.2.2'
|
6
|
+
|
7
|
+
def self.start_command
|
8
|
+
'bundle exec rails s'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create_project(name)
|
12
|
+
# make sure rails gem is installed, install if not
|
13
|
+
gem_dependency = Gem::Dependency.new('rails', VERSION)
|
14
|
+
rails_gem = gem_dependency.matching_specs.max_by(&:version)
|
15
|
+
unless rails_gem
|
16
|
+
puts "Installing rails"
|
17
|
+
result = system('gem', 'install', 'rails', '-v', VERSION)
|
18
|
+
unless result
|
19
|
+
puts "Installation of rails failed! Exiting."
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# create new rails project
|
24
|
+
result = system('rails', 'new', name, '--skip-sprockets', '--skip-bundle', '--skip-yarn')
|
25
|
+
unless result
|
26
|
+
puts "Creation of rails project failed! Exiting."
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.install(root)
|
32
|
+
# config/routes.rb
|
33
|
+
File.delete(File.join('config', 'routes.rb'))
|
34
|
+
result = File.read(File.join(Isomorfeus::Installer.templates_path, 'rails', 'routes.rb'))
|
35
|
+
File.write(File.join('config', 'routes.rb'), result)
|
36
|
+
|
37
|
+
# config/initializers/assets.rb
|
38
|
+
data_hash = { asset_bundler_config: Isomorfeus::Installer.asset_bundler&.asset_bundler_config }
|
39
|
+
Isomorfeus::Installer.create_file_from_template(File.join('rails', 'assets.rb.erb'),
|
40
|
+
File.join('config', 'initializers', 'assets.rb'), data_hash)
|
41
|
+
|
42
|
+
# app/helpers/application_helper.rb
|
43
|
+
File.delete(File.join('app','helpers', 'application_helper.rb'))
|
44
|
+
data_hash = { asset_bundler_includes: Isomorfeus::Installer.asset_bundler&.asset_bundler_includes(true) }
|
45
|
+
Isomorfeus::Installer.create_file_from_template(File.join('rails', 'application_helper.rb.erb'),
|
46
|
+
File.join('app', 'helpers', 'application_helper.rb'), data_hash)
|
47
|
+
|
48
|
+
# app/views/layouts/application.html.erb
|
49
|
+
File.delete(File.join('app','views', 'layouts', 'application.html.erb'))
|
50
|
+
result = File.read(File.join(Isomorfeus::Installer.templates_path, 'rails', 'application.html.erb.head'))
|
51
|
+
result << " <%= #{Isomorfeus::Installer.asset_bundler.script_tag('application.js')} %>\n"
|
52
|
+
result << File.read(File.join(Isomorfeus::Installer.templates_path, 'rails', 'application.html.erb.tail'))
|
53
|
+
File.write(File.join('app','views', 'layouts', 'application.html.erb'), result)
|
54
|
+
|
55
|
+
# app/controllers/application_controller.rb
|
56
|
+
File.delete(File.join('app', 'controllers', 'application_controller.rb'))
|
57
|
+
result = File.read(File.join(Isomorfeus::Installer.templates_path, 'rails', 'application_controller.rb'))
|
58
|
+
File.write(File.join('app', 'controllers' , 'application_controller.rb'), result)
|
59
|
+
|
60
|
+
# app/views/application/index.html
|
61
|
+
Dir.mkdir(File.join('app', 'views', 'application'))
|
62
|
+
result = File.read(File.join(Isomorfeus::Installer.templates_path, 'rails', 'index.html'))
|
63
|
+
File.write(File.join('app', 'views', 'application', 'index.html'), result)
|
64
|
+
|
65
|
+
# app/assets/javascript/application.js
|
66
|
+
File.rename(File.join('app', 'assets', 'javascripts', 'application.js'),
|
67
|
+
File.join('app', 'assets', 'javascripts', 'application.js_orig'))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Isomorfeus::Installer.add_framework('rails', {
|
75
|
+
gems: :has_gemfile,
|
76
|
+
installer: Isomorfeus::Installer::Frameworks::Rails,
|
77
|
+
structure: :app_iso
|
78
|
+
})
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Installer
|
3
|
+
module Frameworks
|
4
|
+
module Roda
|
5
|
+
def self.start_command
|
6
|
+
'bundle exec puma'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.install(root)
|
10
|
+
data_hash = { requires: Isomorfeus::Installer.create_requires,
|
11
|
+
script_tag: Isomorfeus::Installer.asset_bundler&.script_tag(Isomorfeus::Installer.entrypoint),
|
12
|
+
asset_bundler_includes: Isomorfeus::Installer.asset_bundler&.asset_bundler_includes,
|
13
|
+
asset_bundler_config: Isomorfeus::Installer.asset_bundler&.asset_bundler_config }
|
14
|
+
|
15
|
+
Isomorfeus::Installer.create_file_from_template(File.join('roda', 'config_ru.erb'), 'config.ru', data_hash)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Isomorfeus::Installer.add_framework('roda', {
|
23
|
+
gems: [ { name: 'roda', version: '~> 3.15.0' }, { name: 'puma', version: '~> 3.12.0' } ],
|
24
|
+
installer: Isomorfeus::Installer::Frameworks::Roda,
|
25
|
+
structure: :iso
|
26
|
+
})
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Installer
|
3
|
+
module Frameworks
|
4
|
+
module Sinatra
|
5
|
+
def self.start_command
|
6
|
+
'bundle exec puma'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.install(root)
|
10
|
+
data_hash = { requires: Isomorfeus::Installer.create_requires,
|
11
|
+
script_tag: Isomorfeus::Installer.asset_bundler&.script_tag(Isomorfeus::Installer.entrypoint),
|
12
|
+
asset_bundler_includes: Isomorfeus::Installer.asset_bundler&.asset_bundler_includes,
|
13
|
+
asset_bundler_config: Isomorfeus::Installer.asset_bundler&.asset_bundler_config }
|
14
|
+
|
15
|
+
Isomorfeus::Installer.create_file_from_template(File.join('sinatra', 'config_ru.erb'), 'config.ru', data_hash)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Isomorfeus::Installer.add_framework('sinatra', {
|
23
|
+
gems: [ { name: 'sinatra', version: '~> 2.0.4' }, { name: 'puma', version: '~> 3.12.0' } ],
|
24
|
+
installer: Isomorfeus::Installer::Frameworks::Sinatra,
|
25
|
+
structure: :iso
|
26
|
+
})
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if !defined? skip_header %>
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<%= framework_gems %>
|
7
|
+
gem 'foreman'
|
8
|
+
|
9
|
+
gem 'opal', github: 'janbiedermann/opal', branch: 'es6_import_export'
|
10
|
+
|
11
|
+
<%= asset_bundler_gems %>
|
12
|
+
|
13
|
+
gem 'opal-autoloader', '~> 0.0.3'
|
14
|
+
gem 'isomorfeus-redux', '~> 4.0.0'
|
15
|
+
gem 'isomorfeus-react', '~> 16.6.2'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import * as Redux from 'redux';
|
2
|
+
import React from 'react';
|
3
|
+
import ReactDOM from 'react-dom';
|
4
|
+
// import * as History from 'history';
|
5
|
+
import * as ReactRouter from 'react-router';
|
6
|
+
import * as ReactRouterDOM from 'react-router-dom';
|
7
|
+
import { BrowserRouter, Link, NavLink, Route, Switch } from 'react-router-dom';
|
8
|
+
|
9
|
+
global.Redux = Redux;
|
10
|
+
global.React = React;
|
11
|
+
global.ReactDOM = ReactDOM;
|
12
|
+
// global.History = History;
|
13
|
+
global.ReactRouter = ReactRouter;
|
14
|
+
global.ReactRouterDOM = ReactRouterDOM;
|
15
|
+
global.BrowserRouter = BrowserRouter;
|
16
|
+
global.Link = Link;
|
17
|
+
global.NavLink = NavLink;
|
18
|
+
global.Route = Route;
|
19
|
+
global.Switch = Switch;
|
20
|
+
|
21
|
+
import init_app from 'isomorfeus_loader.rb';
|
22
|
+
init_app();
|
23
|
+
Opal.load('isomorfeus_loader');
|
24
|
+
|
25
|
+
if (module.hot) {
|
26
|
+
module.hot.accept('./application.js', function() {
|
27
|
+
console.log('Accepting the updated application.js!');
|
28
|
+
})
|
29
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%= requires %>
|
2
|
+
|
3
|
+
<%= asset_bundler_config %>
|
4
|
+
|
5
|
+
require 'cuba/safe'
|
6
|
+
|
7
|
+
Cuba.plugin Cuba::Safe
|
8
|
+
|
9
|
+
class Cuba
|
10
|
+
<%= asset_bundler_includes %>
|
11
|
+
end
|
12
|
+
|
13
|
+
Cuba.define do
|
14
|
+
on get do
|
15
|
+
on root do
|
16
|
+
html = <<~HTML
|
17
|
+
<html>
|
18
|
+
<head>
|
19
|
+
<title>Welcome</title>
|
20
|
+
#{<%= script_tag %>}
|
21
|
+
</head>
|
22
|
+
<body>
|
23
|
+
<div></div>
|
24
|
+
</body>
|
25
|
+
</html>
|
26
|
+
HTML
|
27
|
+
res.write html
|
28
|
+
end
|
29
|
+
|
30
|
+
on /.*/ do |path|
|
31
|
+
# wildcard to access any component
|
32
|
+
html = <<~HTML
|
33
|
+
<html>
|
34
|
+
<head>
|
35
|
+
<title>Welcome</title>
|
36
|
+
#{<%= script_tag %>}
|
37
|
+
</head>
|
38
|
+
<body>
|
39
|
+
<div></div>
|
40
|
+
</body>
|
41
|
+
</html>
|
42
|
+
HTML
|
43
|
+
res.write html
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
run Cuba
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class <%= app_name %> < LucidApp::Base
|
2
|
+
render do
|
3
|
+
# here may be a router for example:
|
4
|
+
# DIV do
|
5
|
+
# BrowserRouter do
|
6
|
+
# Switch do
|
7
|
+
# Route(path: '/fun/:count', exact: true, component: <%= component_name %>.JS[:react_component])
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
# end
|
11
|
+
|
12
|
+
# or a component:
|
13
|
+
DIV do
|
14
|
+
<%= component_name %>()
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%= component_name %> < LucidComponent::Base
|
2
|
+
render do
|
3
|
+
# when coming from the router example, get the count param:
|
4
|
+
# props.match.count.to_i.times do |i|
|
5
|
+
# # showing the conveniently short 'string param syntax':
|
6
|
+
# DIV "Hello World!"
|
7
|
+
# end
|
8
|
+
|
9
|
+
# showing the 'block param syntax':
|
10
|
+
DIV { "Hello World!" }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
// require requirements used below
|
2
|
+
const path = require('path');
|
3
|
+
const webpack = require('webpack');
|
4
|
+
const OwlResolver = require('opal-webpack-loader/resolver'); // to resolve ruby files
|
5
|
+
|
6
|
+
module.exports = {
|
7
|
+
parallelism: 8,
|
8
|
+
context: path.resolve(__dirname, '<%= isomorfeus_path %>'),
|
9
|
+
mode: "development",
|
10
|
+
optimization: {
|
11
|
+
minimize: false // dont minimize in development, to speed up hot reloads
|
12
|
+
},
|
13
|
+
performance: {
|
14
|
+
maxAssetSize: 20000000, // isomorfeus is some code
|
15
|
+
maxEntrypointSize: 20000000
|
16
|
+
},
|
17
|
+
// use one of these below for source maps, disable for faster hot reloads
|
18
|
+
// devtool: 'source-map', // this works well, good compromise between accuracy and performance
|
19
|
+
// devtool: 'cheap-eval-source-map', // less accurate
|
20
|
+
// devtool: 'inline-source-map', // slowest
|
21
|
+
// devtool: 'inline-cheap-source-map',
|
22
|
+
entry: {
|
23
|
+
application: [path.resolve(__dirname, '<%= entrypoint_path %>')], // entrypoint for isomorfeus
|
24
|
+
},
|
25
|
+
output: {
|
26
|
+
// webpack-serve keeps the output in memory
|
27
|
+
filename: '[name].js',
|
28
|
+
path: path.resolve(__dirname, '<%= asset_output_path %>'),
|
29
|
+
publicPath: 'http://localhost:3035/assets/'
|
30
|
+
},
|
31
|
+
resolve: {
|
32
|
+
plugins: [
|
33
|
+
// this makes it possible for webpack to find ruby files
|
34
|
+
new OwlResolver('resolve', 'resolved')
|
35
|
+
],
|
36
|
+
alias: {
|
37
|
+
'react-dom': 'react-dom/profiling',
|
38
|
+
'schedule/tracing': 'schedule/tracing-profiling',
|
39
|
+
}
|
40
|
+
},
|
41
|
+
plugins: [
|
42
|
+
// both for hot reloading
|
43
|
+
new webpack.NamedModulesPlugin(),
|
44
|
+
new webpack.HotModuleReplacementPlugin()
|
45
|
+
],
|
46
|
+
module: {
|
47
|
+
rules: [
|
48
|
+
{
|
49
|
+
// loader for .scss files
|
50
|
+
// test means "test for for file endings"
|
51
|
+
test: /.scss$/,
|
52
|
+
use: [
|
53
|
+
{
|
54
|
+
loader: "style-loader",
|
55
|
+
options: {
|
56
|
+
hmr: true
|
57
|
+
}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
loader: "css-loader",
|
61
|
+
options: {
|
62
|
+
// sourceMap: true, // set to false to speed up hot reloads
|
63
|
+
minimize: false // set to false to speed up hot reloads
|
64
|
+
}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
loader: "sass-loader",
|
68
|
+
options: {
|
69
|
+
includePaths: [path.resolve(__dirname, '<%= stylesheets_path %>')],
|
70
|
+
// sourceMap: true // set to false to speed up hot reloads
|
71
|
+
}
|
72
|
+
}
|
73
|
+
]
|
74
|
+
},
|
75
|
+
{
|
76
|
+
// loader for .css files
|
77
|
+
test: /.css$/,
|
78
|
+
use: [
|
79
|
+
{
|
80
|
+
loader: "style-loader",
|
81
|
+
options: {
|
82
|
+
hmr: true
|
83
|
+
}
|
84
|
+
},
|
85
|
+
{
|
86
|
+
loader: "css-loader",
|
87
|
+
options: {
|
88
|
+
// sourceMap: true, // set to false to speed up hot reloads
|
89
|
+
minimize: false // set to false to speed up hot reloads
|
90
|
+
}
|
91
|
+
}
|
92
|
+
]
|
93
|
+
},
|
94
|
+
{
|
95
|
+
test: /.(png|svg|jpg|gif)$/,
|
96
|
+
use: [
|
97
|
+
'file-loader'
|
98
|
+
]
|
99
|
+
},
|
100
|
+
{
|
101
|
+
test: /.(woff|woff2|eot|ttf|otf)$/,
|
102
|
+
use: [
|
103
|
+
'file-loader'
|
104
|
+
]
|
105
|
+
},
|
106
|
+
{
|
107
|
+
// opal-webpack-loader will compile and include ruby files in the pack
|
108
|
+
test: /.(rb|js.rb)$/,
|
109
|
+
use: [
|
110
|
+
{
|
111
|
+
loader: 'opal-webpack-loader',
|
112
|
+
options: {
|
113
|
+
// sourceMap: true
|
114
|
+
}
|
115
|
+
}
|
116
|
+
]
|
117
|
+
}
|
118
|
+
]
|
119
|
+
},
|
120
|
+
// configuration for webpack-dev-server
|
121
|
+
devServer: {
|
122
|
+
open: false,
|
123
|
+
lazy: false,
|
124
|
+
port: 3035,
|
125
|
+
hot: true,
|
126
|
+
// hotOnly: true,
|
127
|
+
inline: true,
|
128
|
+
https: false,
|
129
|
+
disableHostCheck: true,
|
130
|
+
headers: {
|
131
|
+
"Access-Control-Allow-Origin": "*",
|
132
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
133
|
+
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
134
|
+
},
|
135
|
+
watchOptions: {
|
136
|
+
// in case of problems with hot reloading uncomment the following two lines:
|
137
|
+
// aggregateTimeout: 250,
|
138
|
+
// poll: 50,
|
139
|
+
ignored: /\bnode_modules\b/
|
140
|
+
},
|
141
|
+
contentBase: path.resolve(__dirname, 'public')
|
142
|
+
// watchContentBase: true
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|