Sha256: 3d7591c078e71726e47cf0ebb250007ae04287ef0407718a887b6460d0dc3e6d
Contents?: true
Size: 1.83 KB
Versions: 9
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require "rails/generators" module ReactOnRails module Generators class ReactWithReduxGenerator < Rails::Generators::Base Rails::Generators.hide_namespace(namespace) source_root(File.expand_path("../templates", __FILE__)) def create_redux_directories dirs = %w[actions constants containers reducers store startup] dirs.each { |name| empty_directory("app/javascript/bundles/HelloWorld/#{name}") } end def copy_base_files base_js_path = "base/base" base_files = %w[app/javascript/bundles/HelloWorld/components/HelloWorld.jsx] base_files.each { |file| copy_file("#{base_js_path}/#{file}", file) } end def copy_base_redux_files base_hello_world_path = "redux/base/app/javascript/bundles/HelloWorld" %w[actions/helloWorldActionCreators.js containers/HelloWorldContainer.js constants/helloWorldConstants.js reducers/helloWorldReducer.js store/helloWorldStore.js startup/HelloWorldApp.jsx].each do |file| copy_file("#{base_hello_world_path}/#{file}", "app/javascript/bundles/HelloWorld/#{file}") end end def create_appropriate_templates base_path = "base/base" base_js_path = "#{base_path}/app/javascript" config = { component_name: "HelloWorldApp", app_relative_path: "../bundles/HelloWorld/startup/HelloWorldApp" } template("#{base_js_path}/packs/registration.js.tt", "app/javascript/packs/hello-world-bundle.js", config) template("#{base_path}/app/views/hello_world/index.html.erb.tt", "app/views/hello_world/index.html.erb", config) end def add_redux_yarn_dependencies run "yarn add redux react-redux" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems