ror_generators 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +15 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/ror_generators/USAGE +8 -0
- data/lib/generators/ror_generators/new_generator.rb +126 -0
- data/lib/generators/ror_generators/templates/client/actions/ActionCreators.jsx.erb +1 -0
- data/lib/generators/ror_generators/templates/client/components/.jsx.erb +14 -0
- data/lib/generators/ror_generators/templates/client/constants/Constants.jsx.erb +0 -0
- data/lib/generators/ror_generators/templates/client/containers/Container.jsx.erb +13 -0
- data/lib/generators/ror_generators/templates/client/package.json.tt +36 -0
- data/lib/generators/ror_generators/templates/client/reducers/Reducer.jsx.erb +22 -0
- data/lib/generators/ror_generators/templates/client/startup/App.jsx.erb +18 -0
- data/lib/generators/ror_generators/templates/client/startup/registration.jsx.erb +8 -0
- data/lib/generators/ror_generators/templates/client/store/Store.jsx.erb +8 -0
- data/lib/generators/ror_generators/templates/client/webpack.config.js.erb +77 -0
- data/lib/generators/ror_generators/templates/server/controller.rb +8 -0
- data/lib/generators/ror_generators/templates/server/index.html.erb +1 -0
- data/lib/generators/ror_generators/templates/server/layout.html.erb +15 -0
- data/lib/ror_generators.rb +5 -0
- data/lib/ror_generators/version.rb +3 -0
- data/ror_generators.gemspec +44 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 59740decbefe5745ae2025a289ecb5b3e26e56f4
|
4
|
+
data.tar.gz: 70f92a808e54c5a52aa40b8695f7cc6b5ce8e56b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53ed32858fadd4c13178f65819456a7d70609741c1284bca5f9923bd152e6d2dd18c3bad104a3204cbf42f3acde259875da91e5e350b844d04bc1487ad3c4acd
|
7
|
+
data.tar.gz: 1345a0765883ba27642dd06aa66eb998b26483209d5c081d0b2485a8030fe3a81570fac47b53f44fe20d48e13af96fe11cd1338bb843b2194c94577938d3d885
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dakotaleemusic@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dakota Martinez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# RorGenerators
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ror_generators`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ror_generators'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ror_generators
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/DakotaLMartinez/ror_generators. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the RorGenerators project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/DakotaLMartinez/ror_generators/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rake/testtask"
|
4
|
+
|
5
|
+
APP_RAKEFILE = File.expand_path("../test/sample/Rakefile", __FILE__)
|
6
|
+
load "rails/tasks/engine.rake"
|
7
|
+
|
8
|
+
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << "test"
|
11
|
+
t.libs << "lib"
|
12
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
13
|
+
end
|
14
|
+
|
15
|
+
task default: :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ror_generators"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module RorGenerators
|
4
|
+
module Generators
|
5
|
+
class NewGenerator < Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def module_name
|
9
|
+
@module_name ||= "#{file_name}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def client_dest_prefix
|
13
|
+
"client/app/bundles/#{module_name}/"
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_react_directories
|
17
|
+
dirs = %w[components containers startup]
|
18
|
+
dirs.each { |name| empty_directory("#{client_dest_prefix}/#{name}") }
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_redux_directories
|
22
|
+
dirs = %w[actions constants reducers store]
|
23
|
+
dirs.each { |name| empty_directory("#{client_dest_prefix}/#{name}") }
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy_template_files
|
27
|
+
client_template_files.each do |file|
|
28
|
+
file_name = file[2] ? module_name.capitalize : module_name
|
29
|
+
template "client/#{file[0]}/#{file[1]}",
|
30
|
+
"#{client_dest_prefix}/#{file[0]}/#{file_name}#{file[1].gsub('.erb', '')}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_route
|
35
|
+
route "resources :#{module_name.downcase.pluralize}, only: :index"
|
36
|
+
end
|
37
|
+
|
38
|
+
def copy_server_files
|
39
|
+
empty_directory("app/views/#{module_name}")
|
40
|
+
template "server/controller.rb", "app/controllers/#{module_name.pluralize}_controller.rb"
|
41
|
+
template "server/index.html.erb", "app/views/#{module_name.pluralize}/index.html.erb"
|
42
|
+
template "server/layout.html.erb", "app/views/layouts/#{module_name}.html.erb"
|
43
|
+
end
|
44
|
+
|
45
|
+
def copy_config_files
|
46
|
+
template "client/package.json.tt", "client/package.json"
|
47
|
+
template "client/webpack.config.js.erb", "client/webpack.config.js"
|
48
|
+
template "client/startup/registration.jsx.erb", "#{client_dest_prefix}/startup/registration.jsx"
|
49
|
+
end
|
50
|
+
|
51
|
+
# def template_package_json
|
52
|
+
# if dest_file_exists?("package.json")
|
53
|
+
# add_yarn_postinstall_script_in_package_json
|
54
|
+
# else
|
55
|
+
# template("base/base/package.json", "package.json")
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def client_template_files
|
62
|
+
[
|
63
|
+
["actions", "ActionCreators.jsx.erb", false],
|
64
|
+
["components", ".jsx.erb", true],
|
65
|
+
["constants", "Constants.jsx.erb", false],
|
66
|
+
["containers", "Container.jsx.erb", true],
|
67
|
+
["reducers", "Reducer.jsx.erb", false],
|
68
|
+
["startup", "App.jsx.erb", true],
|
69
|
+
["store", "Store.jsx.erb", false]
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
# From https://github.com/rails/rails/blob/4c940b2dbfb457f67c6250b720f63501d74a45fd/railties/lib/rails/generators/rails/app/app_generator.rb
|
74
|
+
def app_name
|
75
|
+
@app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root))
|
76
|
+
.tr('\\', "").tr(". ", "_")
|
77
|
+
end
|
78
|
+
|
79
|
+
def defined_app_name
|
80
|
+
defined_app_const_base.underscore
|
81
|
+
end
|
82
|
+
|
83
|
+
def defined_app_const_base
|
84
|
+
Rails.respond_to?(:application) && defined?(Rails::Application) &&
|
85
|
+
Rails.application.is_a?(Rails::Application) && Rails.application.class.name.sub(/::Application$/, "")
|
86
|
+
end
|
87
|
+
|
88
|
+
alias defined_app_const_base? defined_app_const_base
|
89
|
+
|
90
|
+
def app_const_base
|
91
|
+
@app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, "_").squeeze("_").camelize
|
92
|
+
end
|
93
|
+
|
94
|
+
def dest_file_exists?(file)
|
95
|
+
dest_file = File.join(destination_root, file)
|
96
|
+
File.exist?(dest_file) ? dest_file : nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def add_yarn_postinstall_script_in_package_json
|
100
|
+
client_package_json = File.join(destination_root, "package.json")
|
101
|
+
contents = File.read(client_package_json)
|
102
|
+
postinstall = %("postinstall": "cd client && yarn install")
|
103
|
+
if contents =~ /"scripts" *:/
|
104
|
+
replacement = <<-STRING
|
105
|
+
"scripts": {
|
106
|
+
#{postinstall},
|
107
|
+
STRING
|
108
|
+
regexp = / {2}"scripts": {/
|
109
|
+
else
|
110
|
+
regexp = /^{/
|
111
|
+
replacement = <<-STRING.strip_heredoc
|
112
|
+
{
|
113
|
+
"scripts": {
|
114
|
+
#{postinstall}
|
115
|
+
},
|
116
|
+
STRING
|
117
|
+
end
|
118
|
+
|
119
|
+
contents.gsub!(regexp, replacement)
|
120
|
+
File.open(client_package_json, "w+") { |f| f.puts contents }
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
import * as actionTypes from '../constants/<%= module_name %>Constants';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import React from 'react';
|
3
|
+
|
4
|
+
const <%= module_name.capitalize %> = () => (
|
5
|
+
<div>
|
6
|
+
<%= module_name.capitalize %> Component
|
7
|
+
</div>
|
8
|
+
);
|
9
|
+
|
10
|
+
<%= module_name.capitalize %>.propTypes = {
|
11
|
+
|
12
|
+
};
|
13
|
+
|
14
|
+
export default <%= module_name.capitalize %>;
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Simple example of a React "smart" component
|
2
|
+
|
3
|
+
import { connect } from 'react-redux';
|
4
|
+
import <%= module_name.capitalize %> from '../components/<%= module_name.capitalize %>';
|
5
|
+
import * as actions from '../actions/<%= module_name %>ActionCreators';
|
6
|
+
|
7
|
+
// Which part of the Redux global state does our component want to receive as props?
|
8
|
+
const mapStateToProps = (state) => ({ });
|
9
|
+
|
10
|
+
// Don't forget to actually use connect!
|
11
|
+
// Note that we don't export <%= module_name.capitalize %>, but the redux "connected" version of it.
|
12
|
+
// See https://github.com/reactjs/react-redux/blob/master/docs/api.md#examples
|
13
|
+
export default connect(mapStateToProps, actions)(<%= module_name.capitalize %>);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%- require "react_on_rails/version_syntax_converter" -%>
|
2
|
+
{
|
3
|
+
"name": "<%= app_name %>",
|
4
|
+
"private": true,
|
5
|
+
"scripts": {
|
6
|
+
"build:test": "NODE_ENV=test webpack --config webpack.config.js",
|
7
|
+
"build:production": "NODE_ENV=production webpack --config webpack.config.js",
|
8
|
+
"build:development": "NODE_ENV=development webpack -w --config webpack.config.js"
|
9
|
+
},
|
10
|
+
"cacheDirectories": ["node_modules", "client/node_modules"],
|
11
|
+
"dependencies": {
|
12
|
+
"axios": "^0.16.2",
|
13
|
+
"babel-cli": "^6.24.1",
|
14
|
+
"babel-core": "^6.24.1",
|
15
|
+
"babel-loader": "^6.3.2",
|
16
|
+
"babel-runtime": "^6.23.0",
|
17
|
+
"babel-polyfill": "^6.23.0",
|
18
|
+
"babel-preset-es2015": "^6.24.1",
|
19
|
+
"babel-preset-react": "^6.24.1",
|
20
|
+
"babel-preset-stage-2": "^6.24.1",
|
21
|
+
"es5-shim": "^4.5.9",
|
22
|
+
"expose-loader": "^0.7.3",
|
23
|
+
"immutable": "^3.8.1",
|
24
|
+
"imports-loader": "^0.7.1",
|
25
|
+
"js-yaml": "^3.8.2",
|
26
|
+
"react": "^15.5.4",
|
27
|
+
"react-dom": "^15.5.4",
|
28
|
+
"react-on-rails": "<%= VersionSyntaxConverter.new.rubygem_to_npm %>",
|
29
|
+
"react-redux": "^5.0.4",
|
30
|
+
"redux": "^3.6.0",
|
31
|
+
"webpack": "^2.3.3",
|
32
|
+
"webpack-manifest-plugin": "^1.1.0"
|
33
|
+
},
|
34
|
+
"devDependencies": {
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/* eslint new-cap: 0 */
|
2
|
+
|
3
|
+
import Immutable from 'immutable';
|
4
|
+
|
5
|
+
import * as actionTypes from '../constants/<%= module_name %>Constants';
|
6
|
+
|
7
|
+
export const $$initialState = Immutable.fromJS({
|
8
|
+
|
9
|
+
});
|
10
|
+
|
11
|
+
export default function <%= module_name %>Reducer($$state = $$initialState, action = null) {
|
12
|
+
const { type } = action;
|
13
|
+
|
14
|
+
switch (type) {
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
default: {
|
19
|
+
return $$state;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Provider } from 'react-redux';
|
3
|
+
|
4
|
+
import configureStore from '../store/<%= module_name %>Store';
|
5
|
+
import <%= module_name.capitalize %>Container from '../containers/<%= module_name %>Container';
|
6
|
+
|
7
|
+
// See documentation for https://github.com/reactjs/react-redux.
|
8
|
+
// This is how you get props from the Rails view into the redux store.
|
9
|
+
// This code here binds your smart component to the redux store.
|
10
|
+
// railsContext provides contextual information especially useful for server rendering, such as
|
11
|
+
// knowing the locale. See the React on Rails documentation for more info on the railsContext
|
12
|
+
const <%= module_name.capitalize %>App = (props, _railsContext) => (
|
13
|
+
<Provider store={configureStore(props)}>
|
14
|
+
<<%= module_name.capitalize %>Container />
|
15
|
+
</Provider>
|
16
|
+
);
|
17
|
+
|
18
|
+
export default <%= module_name.capitalize %>App;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import ReactOnRails from 'react-on-rails';
|
2
|
+
|
3
|
+
import <%= module_name.capitalize %>App from './<%= module_name.capitalize %>App';
|
4
|
+
|
5
|
+
// This is how react_on_rails can see the <%= module_name.capitalize %> in the browser.
|
6
|
+
ReactOnRails.register({
|
7
|
+
<%= module_name.capitalize %>App,
|
8
|
+
});
|
@@ -0,0 +1,77 @@
|
|
1
|
+
// For inspiration on your webpack configuration, see:
|
2
|
+
// https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client
|
3
|
+
// https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/client
|
4
|
+
|
5
|
+
const webpack = require('webpack');
|
6
|
+
const { resolve } = require('path');
|
7
|
+
|
8
|
+
const ManifestPlugin = require('webpack-manifest-plugin');
|
9
|
+
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
|
10
|
+
|
11
|
+
const configPath = resolve('..', 'config');
|
12
|
+
const { devBuild, manifest, webpackOutputPath, webpackPublicOutputDir } =
|
13
|
+
webpackConfigLoader(configPath);
|
14
|
+
|
15
|
+
const config = {
|
16
|
+
|
17
|
+
context: resolve(__dirname),
|
18
|
+
|
19
|
+
entry: {
|
20
|
+
'webpack-bundle': [
|
21
|
+
'es5-shim/es5-shim',
|
22
|
+
'es5-shim/es5-sham',
|
23
|
+
'babel-polyfill',
|
24
|
+
'./app/bundles/<%= module_name %>/startup/registration',
|
25
|
+
],
|
26
|
+
},
|
27
|
+
|
28
|
+
output: {
|
29
|
+
// Name comes from the entry section.
|
30
|
+
filename: '[name]-[hash].js',
|
31
|
+
|
32
|
+
// Leading slash is necessary
|
33
|
+
publicPath: `/${webpackPublicOutputDir}`,
|
34
|
+
path: webpackOutputPath,
|
35
|
+
},
|
36
|
+
|
37
|
+
resolve: {
|
38
|
+
extensions: ['.js', '.jsx'],
|
39
|
+
},
|
40
|
+
|
41
|
+
plugins: [
|
42
|
+
new webpack.EnvironmentPlugin({
|
43
|
+
NODE_ENV: 'development', // use 'development' unless process.env.NODE_ENV is defined
|
44
|
+
DEBUG: false,
|
45
|
+
}),
|
46
|
+
new ManifestPlugin({ fileName: manifest, writeToFileEmit: true }),
|
47
|
+
],
|
48
|
+
|
49
|
+
module: {
|
50
|
+
rules: [
|
51
|
+
{
|
52
|
+
test: require.resolve('react'),
|
53
|
+
use: {
|
54
|
+
loader: 'imports-loader',
|
55
|
+
options: {
|
56
|
+
shim: 'es5-shim/es5-shim',
|
57
|
+
sham: 'es5-shim/es5-sham',
|
58
|
+
},
|
59
|
+
},
|
60
|
+
},
|
61
|
+
{
|
62
|
+
test: /\.jsx?$/,
|
63
|
+
use: 'babel-loader',
|
64
|
+
exclude: /node_modules/,
|
65
|
+
},
|
66
|
+
],
|
67
|
+
},
|
68
|
+
};
|
69
|
+
|
70
|
+
module.exports = config;
|
71
|
+
|
72
|
+
if (devBuild) {
|
73
|
+
console.log('Webpack dev build for Rails'); // eslint-disable-line no-console
|
74
|
+
module.exports.devtool = 'eval-source-map';
|
75
|
+
} else {
|
76
|
+
console.log('Webpack production build for Rails'); // eslint-disable-line no-console
|
77
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
<%%= react_component("<%= module_name.capitalize.singularize %>App", props: @<%= module_name %>_props, prerender: false) %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ReactOnRailsWithWebpacker</title>
|
5
|
+
<%%= csrf_meta_tags %>
|
6
|
+
|
7
|
+
<%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
8
|
+
<%%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
9
|
+
<%%= javascript_pack_tag 'webpack-bundle' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ror_generators/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ror_generators"
|
8
|
+
spec.version = RorGenerators::VERSION
|
9
|
+
spec.authors = ["Dakota Martinez"]
|
10
|
+
spec.email = ["dakotaleemusic@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Generators for React on Rails module"
|
13
|
+
spec.description = "Adds generators for react on rails modules"
|
14
|
+
spec.homepage = "https://github.com/DakotaLMartinez/RorGenerators.git"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "rails", "~> 5.1.2"
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
spec.add_development_dependency "cucumber"
|
38
|
+
spec.add_development_dependency "aruba"
|
39
|
+
|
40
|
+
spec.add_development_dependency "generator_spec"
|
41
|
+
|
42
|
+
spec.add_dependency "thor"
|
43
|
+
spec.add_dependency "react_on_rails"
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ror_generators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dakota Martinez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.2
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cucumber
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: aruba
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: generator_spec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: thor
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: react_on_rails
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Adds generators for react on rails modules
|
140
|
+
email:
|
141
|
+
- dakotaleemusic@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".travis.yml"
|
148
|
+
- CODE_OF_CONDUCT.md
|
149
|
+
- Gemfile
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- bin/console
|
154
|
+
- bin/setup
|
155
|
+
- lib/generators/ror_generators/USAGE
|
156
|
+
- lib/generators/ror_generators/new_generator.rb
|
157
|
+
- lib/generators/ror_generators/templates/client/actions/ActionCreators.jsx.erb
|
158
|
+
- lib/generators/ror_generators/templates/client/components/.jsx.erb
|
159
|
+
- lib/generators/ror_generators/templates/client/constants/Constants.jsx.erb
|
160
|
+
- lib/generators/ror_generators/templates/client/containers/Container.jsx.erb
|
161
|
+
- lib/generators/ror_generators/templates/client/package.json.tt
|
162
|
+
- lib/generators/ror_generators/templates/client/reducers/Reducer.jsx.erb
|
163
|
+
- lib/generators/ror_generators/templates/client/startup/App.jsx.erb
|
164
|
+
- lib/generators/ror_generators/templates/client/startup/registration.jsx.erb
|
165
|
+
- lib/generators/ror_generators/templates/client/store/Store.jsx.erb
|
166
|
+
- lib/generators/ror_generators/templates/client/webpack.config.js.erb
|
167
|
+
- lib/generators/ror_generators/templates/server/controller.rb
|
168
|
+
- lib/generators/ror_generators/templates/server/index.html.erb
|
169
|
+
- lib/generators/ror_generators/templates/server/layout.html.erb
|
170
|
+
- lib/ror_generators.rb
|
171
|
+
- lib/ror_generators/version.rb
|
172
|
+
- ror_generators.gemspec
|
173
|
+
homepage: https://github.com/DakotaLMartinez/RorGenerators.git
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
metadata:
|
177
|
+
allowed_push_host: https://rubygems.org
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.6.12
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: Generators for React on Rails module
|
198
|
+
test_files: []
|