react-rails-api 0.1.0 → 0.1.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
- data/README.md +34 -9
- data/bin/react-rails +6 -1
- data/lib/react-rails-api/cli.rb +3 -24
- data/lib/react-rails-api/template.rb +4 -1
- data/lib/react-rails-api/templates/package.json.tt +1 -1
- data/lib/react-rails-api/templates/routes.rb.tt +1 -1
- data/lib/react-rails-api/templates/start.rake.tt +7 -2
- data/lib/react-rails-api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7963e08485a82f7460f4919020848425e5f18884037db56d0915f678bc414b5e
|
4
|
+
data.tar.gz: cbfa97efba5b75f73487e25188627ccd0ae807649c0db1a86db49bfd92ded5ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e10164463b98a983115614244f8660b64fb58b600c696dd23f2ac5e4386fe141cafddcbb81234f1eb445671ffcaea1839f73e30103bcbf5cfe0052b31965df43
|
7
|
+
data.tar.gz: 6dae3bc0c8ef08f6646e86f7c2f2e2ef2c50376deb5ec222f2f77a030c021d56074fc25b87c3b6552533a6e9e28144ab1e73a624f6d90c5f8da33e568e10343a
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[]()
|
1
|
+
[](https://github.com/eonu/react-rails-api/blob/38f50a1d30f33cf7b818a5c939fe5d99c1a758a2/react-rails-api.gemspec#L20)
|
2
2
|
[](https://rubygems.org/gems/react-rails-api)
|
3
3
|
[](https://github.com/eonu/react-rails-api/blob/master/LICENSE)
|
4
4
|
|
@@ -6,14 +6,12 @@
|
|
6
6
|
|
7
7
|
All-in-one application generator enabling the integration of a React front-end and a Ruby-on-Rails API back-end with a CMS via ActiveAdmin.
|
8
8
|
|
9
|
-
---
|
10
|
-
|
11
9
|
<p align="center">
|
12
|
-
<img width="
|
10
|
+
<img width="500px" src="https://i.ibb.co/9y3jyBK/react-rails-api.png">
|
13
11
|
<p align="center"><em>Image courtesy of <a href="https://heroku.com">Heroku</a>.</em></p>
|
14
12
|
</p>
|
15
13
|
|
16
|
-
This is an easy-to-use generator to implement the modern web application stack described [here](https://blog.heroku.com/a-rock-solid-modern-web-stack)
|
14
|
+
This is an easy-to-use generator to implement the modern web application stack described [here](https://blog.heroku.com/a-rock-solid-modern-web-stack) by Heroku designer Charlie Gleason.
|
17
15
|
|
18
16
|
## Requirements
|
19
17
|
|
@@ -32,13 +30,40 @@ $ gem install react-rails-api
|
|
32
30
|
|
33
31
|
```bash
|
34
32
|
$ react-rails
|
35
|
-
|
36
|
-
|
37
|
-
react-rails new [PATH] # Initialise a React/Rails API application.
|
33
|
+
Usage:
|
34
|
+
react-rails new [PATH]
|
38
35
|
|
39
36
|
Options:
|
40
37
|
[--database], [--no-database] # Integrate ActiveRecord (and Postgres).
|
41
38
|
# Default: true
|
39
|
+
|
40
|
+
Initialise a React/Rails API application.
|
42
41
|
```
|
43
42
|
|
44
|
-
|
43
|
+
### Creating an application
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ react-rails new demo-app
|
47
|
+
```
|
48
|
+
|
49
|
+
If the `--database` flag is set to true (which is the default), a prompt will also ask if you'd like to integrate [ActiveAdmin](https://activeadmin.info/) into the application.
|
50
|
+
|
51
|
+
If you would not like to integrate ActiveRecord (and a Postgres database), make sure to use the `--no-database` flag:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ react-rails new demo-app --no-database
|
55
|
+
```
|
56
|
+
|
57
|
+
### Running an application
|
58
|
+
|
59
|
+
There are two `rake` tasks that allow you to run development and production builds of an application (using [Foreman](https://github.com/ddollar/foreman)):
|
60
|
+
|
61
|
+
- `start:development` - Starts a development build of the application (running `Procfile.dev`).
|
62
|
+
- `start:production` - Starts a production build of the application (running `Procfile`).
|
63
|
+
|
64
|
+
## More information
|
65
|
+
|
66
|
+
For more information about how to use this stack, please read the following blog posts by Charlie Gleason:
|
67
|
+
|
68
|
+
- https://blog.heroku.com/a-rock-solid-modern-web-stack
|
69
|
+
- https://medium.com/superhighfives/a-top-shelf-web-stack-rails-5-api-activeadmin-create-react-app-de5481b7ec0b
|
data/bin/react-rails
CHANGED
data/lib/react-rails-api/cli.rb
CHANGED
@@ -4,9 +4,8 @@ require_relative 'version'
|
|
4
4
|
class ReactRailsAPI::CLI < Thor
|
5
5
|
TEMPLATE = File.join __dir__, 'template.rb'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
desc 'new [PATH]', "\e[90mInitialise a React/Rails API application.\e[0m"
|
7
|
+
method_option :database, type: :boolean, desc: 'Integrate ActiveRecord (and Postgres).', default: true
|
8
|
+
desc "new [\e[1mPATH\e[0m]", "\e[90mInitialise a React/Rails API application.\e[0m"
|
10
9
|
def new(path)
|
11
10
|
opts = default_options
|
12
11
|
opts << '--database=postgresql' if options[:database]
|
@@ -16,31 +15,11 @@ class ReactRailsAPI::CLI < Thor
|
|
16
15
|
end
|
17
16
|
|
18
17
|
map %w[--version -v] => :version
|
19
|
-
desc '
|
18
|
+
desc '-v', "\e[90mDisplay installed React/Rails API gem version.\e[0m"
|
20
19
|
def version
|
21
20
|
puts ReactRailsAPI::VERSION
|
22
21
|
end
|
23
22
|
|
24
|
-
def self.help(shell, subcommand = false)
|
25
|
-
list = printable_commands(true, subcommand)
|
26
|
-
Thor::Util.thor_classes_in(self).each do |klass|
|
27
|
-
list += klass.printable_commands(false)
|
28
|
-
end
|
29
|
-
list.sort! { |a, b| a[0] <=> b[0] }
|
30
|
-
list.reject! { |e| /.*help.*/.match? e.first }
|
31
|
-
list.map! {|c| c.map {|s| s.gsub('decrypt', ?d).gsub('encrypt', ?e)} }
|
32
|
-
|
33
|
-
if defined?(@package_name) && @package_name
|
34
|
-
shell.say "#{@package_name} commands:"
|
35
|
-
else
|
36
|
-
shell.say "Commands:"
|
37
|
-
end
|
38
|
-
|
39
|
-
shell.print_table(list, :indent => 2, :truncate => true)
|
40
|
-
shell.say
|
41
|
-
class_options_help(shell)
|
42
|
-
end
|
43
|
-
|
44
23
|
no_tasks do
|
45
24
|
def default_options
|
46
25
|
%w[
|
@@ -10,6 +10,7 @@ puts if database
|
|
10
10
|
gem_group :development, :test do
|
11
11
|
gem 'rspec-rails'
|
12
12
|
gem 'sqlite3', '~> 1.3.6'
|
13
|
+
gem 'foreman', '~> 0.85.0'
|
13
14
|
end
|
14
15
|
|
15
16
|
gem_group :production do
|
@@ -105,9 +106,11 @@ after_bundle do
|
|
105
106
|
inside 'client' do
|
106
107
|
# Add a proxy for the Rails API server (on the client)
|
107
108
|
inject_into_file 'package.json', " \"proxy\": \"http://localhost:3001\",\n", after: "\"version\": \"0.1.0\",\n"
|
109
|
+
# Add environment variable for skipping preflight checks (client-level)
|
110
|
+
file '.env', template('.env.tt')
|
108
111
|
end
|
109
112
|
|
110
|
-
# Add environment variable for skipping preflight checks
|
113
|
+
# Add environment variable for skipping preflight checks (top-level)
|
111
114
|
file '.env', template('.env.tt')
|
112
115
|
|
113
116
|
# Prevent out-of-date yarn package errors
|
@@ -1,8 +1,13 @@
|
|
1
1
|
namespace :start do
|
2
|
+
desc 'Start development server'
|
2
3
|
task :development do
|
3
|
-
exec '
|
4
|
+
exec 'foreman start -f Procfile.dev'
|
5
|
+
end
|
6
|
+
|
7
|
+
desc 'Start production server'
|
8
|
+
task :production do
|
9
|
+
exec 'NPM_CONFIG_PRODUCTION=true npm run postinstall && foreman start'
|
4
10
|
end
|
5
11
|
end
|
6
12
|
|
7
|
-
desc 'Start development server'
|
8
13
|
task :start => 'start:development'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Onuonga
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-03-
|
12
|
+
date: 2019-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|