react-rails-api 0.1.4 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fa4d6bae9dfa9a26bf64a325c48a82ffe2ccb155c51cd240554ac9dc81156c6
4
- data.tar.gz: be5fb559bf3a8792c692ae0d6c233729bf42a8d3fd466799782110db73623bc5
3
+ metadata.gz: c9b959a6334b55fb25168c8e5243ac4cb3d978b15f43babe1e287a3b8508e385
4
+ data.tar.gz: 24b052aab15528ea0a749b9b399f5636cd7474eaa63b27c3ca09c19686cf2dd6
5
5
  SHA512:
6
- metadata.gz: 102bdfab109a8f14958cd2e9bd40b8745a732ea02c08b1a1d9948aa576c1b3ee85bfad3fec61e9a7f8d59560b1675e2e9287a737d4edcbd5c6acb8992b466f48
7
- data.tar.gz: cd9be8be45c27a06f5bcbb1b180dfaa6fa4a5d93310b6fd9e0c51aeaeda32aa3826f7ee05d2bfe072fd5d3a7b95198dccdc9f53c97c1a07eca4de1a5f93817df
6
+ metadata.gz: b3800e1472ab63bc088e5f96262c4c76850cef596d362ddfef44bfdbc48e330fc7acc6e7a7227add6af87ca774a3c0718341f339dc575f4b0af1f4e9f004793d
7
+ data.tar.gz: 7c0ed2455fed27f51c76eabfb6b5f8dbbc8e1959e70bfa2d73f9c9f5a50d6f8ccf5d4f5e15a994a8689aedbad2e68c9d0fdf5bb4694e635557b75a53e446e4ca
data/README.md CHANGED
@@ -61,6 +61,21 @@ There are two `rake` tasks that allow you to run development and production buil
61
61
  - `start:development` - Starts a development build of the application (running `Procfile.dev`).
62
62
  - `start:production` - Starts a production build of the application (running `Procfile`).
63
63
 
64
+ ### Troubleshooting and common errors
65
+
66
+ - **Error when precompiling assets on Heroku** (`failed to load command: webpack`)
67
+
68
+ This is often as a result of the auto-detected Ruby and Node.js buildpacks being ran in the wrong order.
69
+
70
+ This can be fixed by running the following commands in the application's directory:
71
+
72
+ ```bash
73
+ $ heroku buildpacks:add heroku/nodejs -i 1
74
+ $ heroku buildpacks:add heroku/ruby -i 2
75
+ ```
76
+
77
+ This ensures that `webpack` is installed before trying to precompile the assets.
78
+
64
79
  ## More information
65
80
 
66
81
  For more information about how to use this stack, please read the following blog posts by Charlie Gleason:
@@ -28,6 +28,7 @@ class ReactRailsAPI::CLI < Thor
28
28
  --skip-coffee
29
29
  --skip-action-cable
30
30
  --skip-action-mailer
31
+ --skip-active-storage
31
32
  --skip-turbolinks
32
33
  --skip-test
33
34
  --skip-bootsnap
@@ -81,8 +81,15 @@ after_bundle do
81
81
 
82
82
  # Add /api scope in config/routes.rb
83
83
  inject_into_file 'routes.rb', template('routes.rb.tt'), before: /^end/
84
+
85
+ inside 'environments' do
86
+ inject_into_file 'production.rb', template('production.rb.tt'), before: /^end/
87
+ end
84
88
  end
85
89
 
90
+ # Add /public/assets to .gitignore
91
+ inject_into_file '.gitignore', template('.gitignore.tt'), after: /^\/public\/packs-test/
92
+
86
93
  if database
87
94
  rails_command 'db:create'
88
95
 
@@ -102,7 +109,7 @@ after_bundle do
102
109
 
103
110
  # Create a production Procfile for running the application
104
111
  file 'Procfile', template('Procfile.tt')
105
- inject_into_file 'Procfile', 'release: bundle exec rake db:migrate', after: "\n" if database
112
+ inject_into_file 'Procfile', "release: bundle exec rake db:migrate\n", after: "\n" if database
106
113
 
107
114
  # Create a rake task for starting the application in the development environment
108
115
  inside File.join('lib', 'tasks') do
@@ -0,0 +1,2 @@
1
+
2
+ /public/assets
@@ -1,2 +1,7 @@
1
1
  # New controllers should inherit from ApiController, not this controller.
2
2
  protect_from_forgery with: :exception
3
+
4
+ # Pass server routes that don't match to the client's index.html
5
+ def fallback_index_html
6
+ render file: 'public/index.html'
7
+ end
@@ -0,0 +1,6 @@
1
+
2
+ # Run the precompile task without invoking Rails
3
+ config.assets.initialize_on_precompile = false
4
+
5
+ # Prevent live asset compilation
6
+ config.assets.compile = false
@@ -4,3 +4,8 @@
4
4
  # resources :products
5
5
  # resources :customers
6
6
  end
7
+
8
+ # Pass server routes that don't match to the client's index.html
9
+ get '*path', to: "application#fallback_index_html", constraints: ->(request) do
10
+ !request.xhr? && request.format.html?
11
+ end
@@ -3,11 +3,6 @@ namespace :start do
3
3
  task :development do
4
4
  exec 'foreman start -f Procfile.dev'
5
5
  end
6
-
7
- desc 'Start production server'
8
- task :production do
9
- exec 'NPM_CONFIG_PRODUCTION=true yarn postinstall && foreman start'
10
- end
11
6
  end
12
7
 
13
8
  task start: 'start:development'
@@ -1,8 +1,8 @@
1
1
  module ReactRailsAPI
2
2
  VERSION = {
3
3
  major: 0,
4
- minor: 1,
5
- patch: 4,
4
+ minor: 2,
5
+ patch: 0,
6
6
  meta: nil
7
7
  }.values.reject(&:nil?).map(&:to_s)*?.
8
8
 
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'react-rails-api'
7
7
  spec.version = ReactRailsAPI::VERSION
8
8
  spec.authors = ['Edwin Onuonga']
9
- spec.email = ['edwinonuonga@gmail.com']
9
+ spec.email = ['ed@eonu.net']
10
10
  spec.license = 'MIT'
11
11
 
12
12
  spec.summary = %q{All-in-one application generator enabling the integration of a React front-end and a Ruby-on-Rails API back-end with ActiveAdmin CMS.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react-rails-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin Onuonga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-18 00:00:00.000000000 Z
11
+ date: 2019-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '12.3'
69
69
  description:
70
70
  email:
71
- - edwinonuonga@gmail.com
71
+ - ed@eonu.net
72
72
  executables:
73
73
  - react-rails
74
74
  extensions: []
@@ -82,11 +82,13 @@ files:
82
82
  - lib/react-rails-api/cli.rb
83
83
  - lib/react-rails-api/template.rb
84
84
  - lib/react-rails-api/templates/.env.tt
85
+ - lib/react-rails-api/templates/.gitignore.tt
85
86
  - lib/react-rails-api/templates/Procfile.dev.tt
86
87
  - lib/react-rails-api/templates/Procfile.tt
87
88
  - lib/react-rails-api/templates/application.rb.tt
88
89
  - lib/react-rails-api/templates/application_controller.rb.tt
89
90
  - lib/react-rails-api/templates/database.yml.tt
91
+ - lib/react-rails-api/templates/production.rb.tt
90
92
  - lib/react-rails-api/templates/routes.rb.tt
91
93
  - lib/react-rails-api/templates/start.rake.tt
92
94
  - lib/react-rails-api/version.rb