react_on_rails 1.2.2 → 2.0.0.beta.1
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 +4 -4
- metadata +5 -126
- data/.babelrc +0 -3
- data/.coveralls.yml +0 -1
- data/.dockerignore +0 -2
- data/.eslintignore +0 -5
- data/.eslintrc +0 -48
- data/.gitignore +0 -26
- data/.jscsrc +0 -26
- data/.rspec +0 -2
- data/.rubocop.yml +0 -70
- data/.scss-lint.yml +0 -205
- data/.travis.yml +0 -41
- data/CHANGELOG.md +0 -42
- data/Dockerfile_tests +0 -12
- data/Gemfile +0 -38
- data/README.md +0 -363
- data/Rakefile +0 -5
- data/app/assets/javascripts/react_on_rails.js +0 -241
- data/app/helpers/react_on_rails_helper.rb +0 -224
- data/docker-compose.yml +0 -11
- data/docs/LICENSE +0 -21
- data/docs/additional_reading/heroku_deployment.md +0 -23
- data/docs/additional_reading/manual_installation.md +0 -142
- data/docs/additional_reading/node_dependencies_and_npm.md +0 -29
- data/docs/additional_reading/optional_configuration.md +0 -34
- data/docs/additional_reading/react-and-redux.md +0 -36
- data/docs/additional_reading/react_router.md +0 -45
- data/docs/additional_reading/server_rendering_tips.md +0 -16
- data/docs/additional_reading/tips.md +0 -10
- data/docs/additional_reading/webpack.md +0 -46
- data/docs/code_of_conduct.md +0 -13
- data/docs/coding-style/linters.md +0 -64
- data/docs/coding-style/style.md +0 -42
- data/docs/contributing.md +0 -62
- data/docs/generator_testing.md +0 -20
- data/docs/install_and_releasing.md +0 -24
- data/docs/sample_generated_js/README.md +0 -4
- data/docs/sample_generated_js/client-generated.js +0 -12
- data/docs/sample_generated_js/server-generated.js +0 -25
- data/lib/generators/USAGE +0 -99
- data/lib/generators/react_on_rails/base_generator.rb +0 -198
- data/lib/generators/react_on_rails/bootstrap_generator.rb +0 -91
- data/lib/generators/react_on_rails/dev_tests_generator.rb +0 -30
- data/lib/generators/react_on_rails/generator_errors.rb +0 -15
- data/lib/generators/react_on_rails/generator_helper.rb +0 -58
- data/lib/generators/react_on_rails/heroku_deployment_generator.rb +0 -30
- data/lib/generators/react_on_rails/install_generator.rb +0 -111
- data/lib/generators/react_on_rails/js_linters_generator.rb +0 -19
- data/lib/generators/react_on_rails/react_no_redux_generator.rb +0 -41
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +0 -52
- data/lib/generators/react_on_rails/ruby_linters_generator.rb +0 -33
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +0 -4
- data/lib/generators/react_on_rails/templates/base/base/REACT_ON_RAILS.md +0 -16
- data/lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb +0 -5
- data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +0 -5
- data/lib/generators/react_on_rails/templates/base/base/client/.babelrc +0 -3
- data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md +0 -3
- data/lib/generators/react_on_rails/templates/base/base/client/app/bundles/HelloWorld/startup/globals.jsx.tt +0 -5
- data/lib/generators/react_on_rails/templates/base/base/client/index.jade +0 -15
- data/lib/generators/react_on_rails/templates/base/base/client/npm-shrinkwrap.json +0 -2907
- data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +0 -98
- data/lib/generators/react_on_rails/templates/base/base/client/server.js +0 -64
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.base.config.js.tt +0 -67
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.hot.config.js.tt +0 -67
- data/lib/generators/react_on_rails/templates/base/base/client/webpack.client.rails.config.js +0 -41
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +0 -28
- data/lib/generators/react_on_rails/templates/base/base/lib/tasks/assets.rake.tt +0 -26
- data/lib/generators/react_on_rails/templates/base/base/lib/tasks/linters.rake.tt +0 -88
- data/lib/generators/react_on_rails/templates/base/base/package.json +0 -31
- data/lib/generators/react_on_rails/templates/base/server_rendering/client/app/bundles/HelloWorld/startup/serverGlobals.jsx +0 -3
- data/lib/generators/react_on_rails/templates/base/server_rendering/client/webpack.server.rails.config.js +0 -40
- data/lib/generators/react_on_rails/templates/bootstrap/app/assets/stylesheets/_bootstrap-custom.scss +0 -63
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_post-bootstrap.scss +0 -10
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_pre-bootstrap.scss +0 -8
- data/lib/generators/react_on_rails/templates/bootstrap/client/assets/stylesheets/_react-on-rails-sass-helper.scss +0 -19
- data/lib/generators/react_on_rails/templates/bootstrap/client/bootstrap-sass.config.js +0 -89
- data/lib/generators/react_on_rails/templates/dev_tests/.rspec +0 -2
- data/lib/generators/react_on_rails/templates/dev_tests/spec/features/hello_world_spec.rb +0 -25
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +0 -57
- data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +0 -21
- data/lib/generators/react_on_rails/templates/dev_tests/spec/spec_helper.rb +0 -95
- data/lib/generators/react_on_rails/templates/heroku_deployment/.buildpacks +0 -2
- data/lib/generators/react_on_rails/templates/heroku_deployment/Procfile +0 -1
- data/lib/generators/react_on_rails/templates/heroku_deployment/config/puma.rb +0 -15
- data/lib/generators/react_on_rails/templates/js_linters/client/.eslintignore +0 -1
- data/lib/generators/react_on_rails/templates/js_linters/client/.eslintrc +0 -48
- data/lib/generators/react_on_rails/templates/js_linters/client/.jscsrc +0 -18
- data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +0 -39
- data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +0 -33
- data/lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx.tt +0 -12
- data/lib/generators/react_on_rails/templates/no_redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +0 -11
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx +0 -8
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx +0 -48
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx +0 -8
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/containers/HelloWorld.jsx +0 -43
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx +0 -21
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/reducers/index.jsx +0 -14
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/startup/HelloWorldAppClient.jsx.tt +0 -21
- data/lib/generators/react_on_rails/templates/redux/base/client/app/bundles/HelloWorld/store/helloWorldStore.jsx +0 -35
- data/lib/generators/react_on_rails/templates/redux/base/client/app/lib/middlewares/loggerMiddleware.js +0 -20
- data/lib/generators/react_on_rails/templates/redux/server_rendering/client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx +0 -21
- data/lib/generators/react_on_rails/templates/ruby_linters/.rubocop.yml +0 -26
- data/lib/generators/react_on_rails/templates/ruby_linters/.scss-lint.yml +0 -205
- data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/brakeman.rake +0 -17
- data/lib/generators/react_on_rails/templates/ruby_linters/lib/tasks/ci.rake +0 -33
- data/lib/generators/react_on_rails/templates/ruby_linters/ruby-lint.yml +0 -20
- data/lib/react_on_rails.rb +0 -6
- data/lib/react_on_rails/configuration.rb +0 -53
- data/lib/react_on_rails/engine.rb +0 -7
- data/lib/react_on_rails/prerender_error.rb +0 -31
- data/lib/react_on_rails/server_rendering_pool.rb +0 -111
- data/lib/react_on_rails/version.rb +0 -3
- data/rakelib/docker.rake +0 -33
- data/rakelib/dummy_apps.rake +0 -29
- data/rakelib/example_type.rb +0 -160
- data/rakelib/examples.rake +0 -103
- data/rakelib/examples_config.yml +0 -19
- data/rakelib/lint.rake +0 -37
- data/rakelib/run_rspec.rake +0 -65
- data/rakelib/task_helpers.rb +0 -44
- data/react_on_rails.gemspec +0 -31
- data/ruby-lint.yml +0 -24
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
require File.expand_path("../generator_helper", __FILE__)
|
|
3
|
-
require File.expand_path("../generator_errors", __FILE__)
|
|
4
|
-
include GeneratorHelper
|
|
5
|
-
include GeneratorErrors
|
|
6
|
-
|
|
7
|
-
module ReactOnRails
|
|
8
|
-
module Generators
|
|
9
|
-
class BootstrapGenerator < Rails::Generators::Base
|
|
10
|
-
Rails::Generators.hide_namespace(namespace)
|
|
11
|
-
source_root(File.expand_path("../templates", __FILE__))
|
|
12
|
-
|
|
13
|
-
def copy_bootstrap_files
|
|
14
|
-
base_path = "bootstrap/"
|
|
15
|
-
%w(app/assets/stylesheets/_bootstrap-custom.scss
|
|
16
|
-
client/assets/stylesheets/_post-bootstrap.scss
|
|
17
|
-
client/assets/stylesheets/_pre-bootstrap.scss
|
|
18
|
-
client/assets/stylesheets/_react-on-rails-sass-helper.scss
|
|
19
|
-
client/bootstrap-sass.config.js).each { |file| copy_file(base_path + file, file) }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# if there still is not application.scss, just create one
|
|
23
|
-
def create_application_scss_if_necessary
|
|
24
|
-
path = File.join(destination_root, "app/assets/stylesheets/application.scss")
|
|
25
|
-
return if File.exist?(path)
|
|
26
|
-
File.open(path, "w") { |f| f.puts "// Created by React on Rails gem\n\n" }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def prepend_to_application_scss
|
|
30
|
-
data = <<-DATA.strip_heredoc
|
|
31
|
-
// DO NOT REQUIRE TREE! It will interfere with load order!
|
|
32
|
-
|
|
33
|
-
// Account for differences between Rails and Webpack Sass code.
|
|
34
|
-
$rails: true;
|
|
35
|
-
|
|
36
|
-
// Included from bootstrap-sprockets gem and loaded in app/assets/javascripts/application.rb
|
|
37
|
-
@import 'bootstrap-sprockets';
|
|
38
|
-
|
|
39
|
-
// Customizations - needs to be imported after bootstrap-sprocket but before bootstrap-custom!
|
|
40
|
-
// The _pre-bootstrap.scss file is located under
|
|
41
|
-
// client/assets/stylesheets, which has been added to the Rails asset
|
|
42
|
-
// pipeline search path. See config/application.rb.
|
|
43
|
-
@import 'pre-bootstrap';
|
|
44
|
-
|
|
45
|
-
// These scss files are located under client/assets/stylesheets
|
|
46
|
-
// (which has been added to the Rails asset pipeline search path in config/application.rb).
|
|
47
|
-
@import 'bootstrap-custom';
|
|
48
|
-
|
|
49
|
-
// This must come after all the boostrap styles are loaded so that these styles can override those.
|
|
50
|
-
@import 'post-bootstrap';
|
|
51
|
-
|
|
52
|
-
DATA
|
|
53
|
-
|
|
54
|
-
application_scss = File.join(destination_root, "app/assets/stylesheets/application.scss")
|
|
55
|
-
|
|
56
|
-
if File.exist?(application_scss)
|
|
57
|
-
append_to_file(application_scss, data)
|
|
58
|
-
else
|
|
59
|
-
GeneratorErrors.add_error(return_setup_file_error(application_scss, data))
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def strip_application_scss_of_incompatible_sprockets_statements
|
|
64
|
-
application_scss = File.join(destination_root, "app/assets/stylesheets/application.scss")
|
|
65
|
-
gsub_file(application_scss, "*= require_tree .", "")
|
|
66
|
-
gsub_file(application_scss, "*= require_self", "")
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def add_bootstrap_sprockets_to_gemfile
|
|
70
|
-
append_to_file("Gemfile", "gem 'bootstrap-sass'\n")
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def add_bootstrap_sprockets_to_application_js
|
|
74
|
-
data = <<-DATA.strip_heredoc
|
|
75
|
-
|
|
76
|
-
// bootstrap-sprockets depends on generated/vendor-bundle for jQuery.
|
|
77
|
-
//= require bootstrap-sprockets
|
|
78
|
-
|
|
79
|
-
DATA
|
|
80
|
-
|
|
81
|
-
app_js_path = "app/assets/javascripts/application.js"
|
|
82
|
-
found_app_js = dest_file_exists?(app_js_path) || dest_file_exists?(app_js_path + ".coffee")
|
|
83
|
-
if found_app_js
|
|
84
|
-
append_to_file(found_app_js, data)
|
|
85
|
-
else
|
|
86
|
-
create_file(app_js_path, data)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
require_relative "generator_helper"
|
|
3
|
-
include GeneratorHelper
|
|
4
|
-
|
|
5
|
-
module ReactOnRails
|
|
6
|
-
module Generators
|
|
7
|
-
class DevTestsGenerator < Rails::Generators::Base
|
|
8
|
-
Rails::Generators.hide_namespace(namespace)
|
|
9
|
-
source_root(File.expand_path("../templates/dev_tests", __FILE__))
|
|
10
|
-
|
|
11
|
-
def copy_rspec_files
|
|
12
|
-
%w(spec/spec_helper.rb
|
|
13
|
-
spec/rails_helper.rb
|
|
14
|
-
spec/simplecov_helper.rb
|
|
15
|
-
.rspec).each { |file| copy_file(file) }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def copy_tests
|
|
19
|
-
%w(spec/features/hello_world_spec.rb).each { |file| copy_file(file) }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def add_test_related_gems_to_gemfile
|
|
23
|
-
gem("rspec-rails", group: :test)
|
|
24
|
-
gem("capybara", group: :test)
|
|
25
|
-
gem("selenium-webdriver", group: :test)
|
|
26
|
-
gem("coveralls", require: false)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module GeneratorHelper
|
|
2
|
-
# Takes a relative path from the destination root, such as `.gitignore` or `app/assets/javascripts/application.js`
|
|
3
|
-
def dest_file_exists?(file)
|
|
4
|
-
dest_file = File.join(destination_root, file)
|
|
5
|
-
File.exist?(dest_file) ? dest_file : nil
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def dest_dir_exists?(dir)
|
|
9
|
-
dest_dir = File.join(destination_root, dir)
|
|
10
|
-
Dir.exist?(dest_dir) ? dest_dir : nil
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Takes the missing file and the
|
|
14
|
-
def puts_setup_file_error(file, data)
|
|
15
|
-
puts "** #{file} was not found."
|
|
16
|
-
puts "Please add the following content to your #{file} file:"
|
|
17
|
-
puts "\n#{data}\n"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def return_setup_file_error(file, data)
|
|
21
|
-
error = ""
|
|
22
|
-
error << "** #{file} was not found.\n"
|
|
23
|
-
error << "Please add the following content to your #{file} file:\n"
|
|
24
|
-
error << "\n#{data}\n"
|
|
25
|
-
error
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def empty_directory_with_keep_file(destination, config = {})
|
|
29
|
-
empty_directory(destination, config)
|
|
30
|
-
keep_file(destination)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def keep_file(destination)
|
|
34
|
-
create_file("#{destination}/.keep") unless options[:skip_keeps]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# As opposed to Rails::Generators::Testing.create_link, which creates a link pointing to
|
|
38
|
-
# source_root, this symlinks a file in destination_root to a file also in
|
|
39
|
-
# destination_root.
|
|
40
|
-
def symlink_dest_file_to_dest_file(target, link)
|
|
41
|
-
target_pathname = Pathname.new(File.join(destination_root, target))
|
|
42
|
-
link_pathname = Pathname.new(File.join(destination_root, link))
|
|
43
|
-
|
|
44
|
-
link_directory = link_pathname.dirname
|
|
45
|
-
link_basename = link_pathname.basename
|
|
46
|
-
target_relative_path = target_pathname.relative_path_from(link_directory)
|
|
47
|
-
|
|
48
|
-
`cd #{link_directory} && ln -s #{target_relative_path} #{link_basename}`
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def copy_file_and_missing_parent_directories(source_file, destination_file = nil)
|
|
52
|
-
destination_file = source_file unless destination_file
|
|
53
|
-
destination_path = Pathname.new(destination_file)
|
|
54
|
-
parent_directories = destination_path.dirname
|
|
55
|
-
empty_directory(parent_directories) unless dest_dir_exists?(parent_directories)
|
|
56
|
-
copy_file source_file, destination_file
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
require File.expand_path("../generator_helper", __FILE__)
|
|
3
|
-
include GeneratorHelper
|
|
4
|
-
|
|
5
|
-
module ReactOnRails
|
|
6
|
-
module Generators
|
|
7
|
-
class HerokuDeploymentGenerator < Rails::Generators::Base
|
|
8
|
-
Rails::Generators.hide_namespace(namespace)
|
|
9
|
-
source_root(File.expand_path("../templates", __FILE__))
|
|
10
|
-
|
|
11
|
-
def copy_heroku_deployment_files
|
|
12
|
-
base_path = "heroku_deployment"
|
|
13
|
-
%w(.buildpacks
|
|
14
|
-
Procfile
|
|
15
|
-
config/puma.rb).each { |file| copy_file("#{base_path}/#{file}", file) }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def add_heroku_production_gems
|
|
19
|
-
gem_text = <<-GEMS.strip_heredoc
|
|
20
|
-
|
|
21
|
-
# For Heroku deployment
|
|
22
|
-
gem 'rails_12factor', group: :production
|
|
23
|
-
gem 'puma', group: :production
|
|
24
|
-
|
|
25
|
-
GEMS
|
|
26
|
-
append_to_file("Gemfile", gem_text)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
require File.expand_path("../generator_helper", __FILE__)
|
|
3
|
-
require File.expand_path("../generator_errors", __FILE__)
|
|
4
|
-
include GeneratorHelper
|
|
5
|
-
include GeneratorErrors
|
|
6
|
-
|
|
7
|
-
module ReactOnRails
|
|
8
|
-
module Generators
|
|
9
|
-
class InstallGenerator < Rails::Generators::Base
|
|
10
|
-
# fetch USAGE file for details generator description
|
|
11
|
-
source_root(File.expand_path("../", __FILE__))
|
|
12
|
-
|
|
13
|
-
# --redux
|
|
14
|
-
class_option :redux,
|
|
15
|
-
type: :boolean,
|
|
16
|
-
default: false,
|
|
17
|
-
desc: "Install Redux gems and Redux version of Hello World Example. Default: false",
|
|
18
|
-
aliases: "-R"
|
|
19
|
-
# --server-rendering
|
|
20
|
-
class_option :server_rendering,
|
|
21
|
-
type: :boolean,
|
|
22
|
-
default: false,
|
|
23
|
-
desc: "Add necessary files and configurations for server-side rendering. Default: false",
|
|
24
|
-
aliases: "-S"
|
|
25
|
-
# --skip-js-linters
|
|
26
|
-
class_option :skip_js_linters,
|
|
27
|
-
type: :boolean,
|
|
28
|
-
default: false,
|
|
29
|
-
desc: "Skip installing JavaScript linting files. Default: false",
|
|
30
|
-
aliases: "-j"
|
|
31
|
-
# --ruby-linters
|
|
32
|
-
class_option :ruby_linters,
|
|
33
|
-
type: :boolean,
|
|
34
|
-
default: false,
|
|
35
|
-
desc: "Install ruby linting files, tasks, and configs. Default: false",
|
|
36
|
-
aliases: "-L"
|
|
37
|
-
# --ruby-linters
|
|
38
|
-
class_option :heroku_deployment,
|
|
39
|
-
type: :boolean,
|
|
40
|
-
default: false,
|
|
41
|
-
desc: "Install files necessary for deploying to Heroku. Default: false",
|
|
42
|
-
aliases: "-H"
|
|
43
|
-
# --skip-bootstrap
|
|
44
|
-
class_option :skip_bootstrap,
|
|
45
|
-
type: :boolean,
|
|
46
|
-
default: false,
|
|
47
|
-
desc: "Skip integrating Bootstrap and don't initialize files and regarding configs. Default: false",
|
|
48
|
-
aliases: "-b"
|
|
49
|
-
|
|
50
|
-
def run_generators # rubocop:disable Metrics/CyclomaticComplexity
|
|
51
|
-
unless installation_prerequisites_met?
|
|
52
|
-
print_errors
|
|
53
|
-
return
|
|
54
|
-
end
|
|
55
|
-
warn_if_nvm_is_not_installed
|
|
56
|
-
invoke_generators
|
|
57
|
-
print_errors
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
private
|
|
61
|
-
|
|
62
|
-
def print_errors
|
|
63
|
-
GeneratorErrors.errors.each { |errors| puts errors }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def invoke_generators # rubocop:disable Metrics/CyclomaticComplexity
|
|
67
|
-
invoke "react_on_rails:base"
|
|
68
|
-
invoke "react_on_rails:react_no_redux" unless options.redux?
|
|
69
|
-
invoke "react_on_rails:react_with_redux" if options.redux?
|
|
70
|
-
invoke "react_on_rails:js_linters" unless options.skip_js_linters?
|
|
71
|
-
invoke "react_on_rails:ruby_linters" if options.ruby_linters?
|
|
72
|
-
invoke "react_on_rails:heroku_deployment" if options.heroku_deployment?
|
|
73
|
-
invoke "react_on_rails:bootstrap" unless options.skip_bootstrap?
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# NOTE: other requirements for existing files such as .gitignore or application.
|
|
77
|
-
# js(.coffee) are not checked by this method, but instead produce warning messages
|
|
78
|
-
# and allow the build to continue
|
|
79
|
-
def installation_prerequisites_met?
|
|
80
|
-
!(missing_node? || missing_npm? || uncommitted_changes?)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def missing_npm?
|
|
84
|
-
return false unless `which npm`.blank?
|
|
85
|
-
error = "** npm is required. Please install it before continuing."
|
|
86
|
-
error << "https://www.npmjs.com/"
|
|
87
|
-
GeneratorErrors.add_error(error)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def missing_node?
|
|
91
|
-
return false unless `which node`.blank?
|
|
92
|
-
error = "** nodejs is required. Please install it before continuing."
|
|
93
|
-
error << "https://nodejs.org/en/"
|
|
94
|
-
GeneratorErrors.add_error(error)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def uncommitted_changes?
|
|
98
|
-
return false if ENV["COVERAGE"]
|
|
99
|
-
status = `git status`
|
|
100
|
-
return false if status.include?("nothing to commit, working directory clean")
|
|
101
|
-
error = "** You have uncommitted code. Please commit or stash your changes before continuing"
|
|
102
|
-
GeneratorErrors.add_error(error)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def warn_if_nvm_is_not_installed
|
|
106
|
-
return true unless `which nvm`.blank?
|
|
107
|
-
GeneratorErrors.add_error("** nvm is advised. Please consider installing it. https://github.com/creationix/nvm")
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
|
|
3
|
-
module ReactOnRails
|
|
4
|
-
module Generators
|
|
5
|
-
class JsLintersGenerator < Rails::Generators::Base
|
|
6
|
-
Rails::Generators.hide_namespace(namespace)
|
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
|
8
|
-
|
|
9
|
-
# NOTE: linter modules are included via template in base/base/client/package.json.tt
|
|
10
|
-
|
|
11
|
-
def copy_js_linter_config_files
|
|
12
|
-
base_path = "js_linters/"
|
|
13
|
-
%w(client/.eslintrc
|
|
14
|
-
client/.eslintignore
|
|
15
|
-
client/.jscsrc).each { |file| copy_file(base_path + file, file) }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
require File.expand_path("../generator_helper", __FILE__)
|
|
3
|
-
include GeneratorHelper
|
|
4
|
-
|
|
5
|
-
module ReactOnRails
|
|
6
|
-
module Generators
|
|
7
|
-
class ReactNoReduxGenerator < Rails::Generators::Base
|
|
8
|
-
Rails::Generators.hide_namespace(namespace)
|
|
9
|
-
source_root(File.expand_path("../templates", __FILE__))
|
|
10
|
-
|
|
11
|
-
# --server-rendering
|
|
12
|
-
class_option :server_rendering,
|
|
13
|
-
type: :boolean,
|
|
14
|
-
default: false,
|
|
15
|
-
desc: "Configure for server-side rendering of webpack JavaScript",
|
|
16
|
-
aliases: "-S"
|
|
17
|
-
|
|
18
|
-
def copy_base_files
|
|
19
|
-
base_path = "no_redux/base/"
|
|
20
|
-
%w(client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
|
|
21
|
-
client/app/bundles/HelloWorld/containers/HelloWorld.jsx).each do |file|
|
|
22
|
-
copy_file(base_path + file, file)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def copy_server_rendering_files_if_appropriate
|
|
27
|
-
return unless options.server_rendering?
|
|
28
|
-
base_path = "no_redux/server_rendering/"
|
|
29
|
-
%w(client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx).each do |file|
|
|
30
|
-
copy_file(base_path + file, file)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def template_appropriate_version_of_hello_world_app_client
|
|
35
|
-
filename = options.server_rendering? ? "HelloWorldAppClient.jsx" : "HelloWorldApp.jsx"
|
|
36
|
-
location = "client/app/bundles/HelloWorld/startup"
|
|
37
|
-
template("no_redux/base/#{location}/HelloWorldAppClient.jsx.tt", "#{location}/#{filename}")
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
|
|
3
|
-
module ReactOnRails
|
|
4
|
-
module Generators
|
|
5
|
-
class ReactWithReduxGenerator < Rails::Generators::Base
|
|
6
|
-
Rails::Generators.hide_namespace(namespace)
|
|
7
|
-
source_root(File.expand_path("../templates", __FILE__))
|
|
8
|
-
|
|
9
|
-
# --server-rendering
|
|
10
|
-
class_option :server_rendering,
|
|
11
|
-
type: :boolean,
|
|
12
|
-
default: false,
|
|
13
|
-
desc: "Configure for server-side rendering of webpack JavaScript",
|
|
14
|
-
aliases: "-S"
|
|
15
|
-
|
|
16
|
-
def create_redux_directories
|
|
17
|
-
dirs = %w(actions constants reducers store)
|
|
18
|
-
dirs.each { |name| empty_directory("client/app/bundles/HelloWorld/#{name}") }
|
|
19
|
-
|
|
20
|
-
empty_directory("client/app/lib/middlewares")
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def copy_base_redux_files
|
|
24
|
-
base_path = "redux/base/"
|
|
25
|
-
%w(client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
|
|
26
|
-
client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
|
|
27
|
-
client/app/bundles/HelloWorld/containers/HelloWorld.jsx
|
|
28
|
-
client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx
|
|
29
|
-
client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx
|
|
30
|
-
client/app/bundles/HelloWorld/reducers/index.jsx
|
|
31
|
-
client/app/bundles/HelloWorld/store/helloWorldStore.jsx
|
|
32
|
-
client/app/lib/middlewares/loggerMiddleware.js).each do |file|
|
|
33
|
-
copy_file(base_path + file, file)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def copy_server_rendering_redux_files
|
|
38
|
-
return unless options.server_rendering?
|
|
39
|
-
base_path = "redux/server_rendering/"
|
|
40
|
-
%w(client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx).each do |file|
|
|
41
|
-
copy_file(base_path + file, file)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def template_appropriate_version_of_hello_world_app_client
|
|
46
|
-
filename = options.server_rendering? ? "HelloWorldAppClient.jsx" : "HelloWorldApp.jsx"
|
|
47
|
-
location = "client/app/bundles/HelloWorld/startup"
|
|
48
|
-
template("redux/base/#{location}/HelloWorldAppClient.jsx.tt", "#{location}/#{filename}")
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|