react-rails-api 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d500f5dea293c6b19ed33b91ec10fa0d13ca81f4707c3b1cc4156936a59bc3ab
4
- data.tar.gz: 7a76b3afd69d353d2cbb55f3e369ccb74944a3a9028042d59e65fd83b131e205
3
+ metadata.gz: 4e5a9f24471e54d7e380dbc368e23e2b274fabb05846966b178a793da99dde96
4
+ data.tar.gz: 3afb77d6f33dca816aeb0d20503721f7d84ddeb884ede10f122cf7d4f388293e
5
5
  SHA512:
6
- metadata.gz: 6085938a699828539279ce9eee4a83524abc2179c392477ee32ac87e05ae9988164571639a9d76662e18cf01dc844bd477e0578cb57073df95fedd63ff674f64
7
- data.tar.gz: 8b658ab9cbbc91530c7567a6a0005538489594efb73a485796a03ec2e3ab47febabfe60cbd8e8bcddfc75e0f52e3d54102fac65ba8a29278731afecdb2055e62
6
+ metadata.gz: dcf69f0e4295aed11496fc64d65c80b9d8330810135bed47740f078e7f78dcd45f4f95bbda79cc87b6728da09a55e4927dcf716a2d77bd970c4377440954cbc4
7
+ data.tar.gz: 5086f45d6649ff1c70d55581aa7a3118ac3fe009d9406ffcd226710e6fd49ed2479c626767f07a1ea1f5c7ac111c7c849d906c738f08a544025fa384c7b6f1ec
data/README.md CHANGED
@@ -17,8 +17,8 @@ This is an easy-to-use generator to implement the modern web application stack d
17
17
 
18
18
  - [**Ruby**](https://www.ruby-lang.org/en/) `~> 2.5`
19
19
  - [**Rails**](https://rubyonrails.org/) `~> 5.2`
20
- - [**Node**](https://nodejs.org/en/) `11.11.0`: *Recommend installing this with [NVM](https://github.com/creationix/nvm).*
21
- - [**Yarn**](https://yarnpkg.com/en/) `1.13.0`: *Recommend installing Node separately from this, rather than as a dependency.*
20
+ - [**Node**](https://nodejs.org/en/) `^11`: *Recommend installing this with [NVM](https://github.com/creationix/nvm).*
21
+ - [**Yarn**](https://yarnpkg.com/en/) `^1.13`: *Recommend installing Node separately from this, rather than as a dependency.*
22
22
 
23
23
  ## Installation
24
24
 
@@ -1,8 +1,18 @@
1
+ require 'react-rails-api/version'
2
+ require 'json'
3
+
1
4
  # Loads a template from ./templates
2
5
  def template(name)
3
6
  File.open(File.join __dir__, 'templates', name).read
4
7
  end
5
8
 
9
+ # Allows for modification of JSON files
10
+ def modify_json(file)
11
+ hash = JSON.parse File.read(file), symbolize_names: true
12
+ yield hash if block_given?
13
+ File.open(file, ?w) {|f| f.write JSON.pretty_generate(hash)}
14
+ end
15
+
6
16
  database = !ARGV.include?('--skip-active-record')
7
17
  active_admin = database ? yes?("\nUse ActiveAdmin? (Y/n):") : false
8
18
  puts if database
@@ -61,7 +71,7 @@ after_bundle do
61
71
 
62
72
  inside 'config' do
63
73
  # Include the railtie for sprockets
64
- uncomment_lines 'application.rb', /require \"sprockets\/railtie\"/
74
+ uncomment_lines 'application.rb', "require \"sprockets/railtie\""
65
75
 
66
76
  # Add ActiveAdmin configuration on config/application.rb
67
77
  inject_into_file 'application.rb', template('application.rb.tt'), before: /^ end/ if active_admin
@@ -74,10 +84,12 @@ after_bundle do
74
84
  end
75
85
 
76
86
  if database
87
+ rails_command 'db:create'
88
+
77
89
  if active_admin
78
90
  # Integrate ActiveAdmin and Devise CMS into the application
91
+ run 'spring stop'
79
92
  generate 'active_admin:install'
80
- generate 'devise:views'
81
93
  end
82
94
 
83
95
  # Run a database migration and seed the database
@@ -98,14 +110,26 @@ after_bundle do
98
110
  end
99
111
 
100
112
  # Create a top-level package.json that tells Heroku how to compile the Create React App
101
- file 'package.json', template('package.json.tt'), force: true
113
+ modify_json 'package.json' do |json|
114
+ json[:name] = 'api'
115
+ json[:license] = 'MIT'
116
+ json[:engines] = {
117
+ node: ReactRailsAPI::ENGINE_VERSIONS[:node],
118
+ yarn: ReactRailsAPI::ENGINE_VERSIONS[:yarn]
119
+ }
120
+ json[:scripts] = {
121
+ build: "yarn --cwd client install && yarn --cwd client build",
122
+ deploy: "cp -a client/build/. public/",
123
+ postinstall: "yarn build && yarn deploy"
124
+ }
125
+ end
102
126
 
103
127
  # Create the React application (client)
104
128
  run 'yarn create react-app client'
105
129
 
106
130
  inside 'client' do
107
131
  # Add a proxy for the Rails API server (on the client)
108
- inject_into_file 'package.json', " \"proxy\": \"http://localhost:3001\",\n", after: "\"version\": \"0.1.0\",\n"
132
+ modify_json('package.json') {|json| json[:proxy] = 'http://localhost:3001'}
109
133
  # Add environment variable for skipping preflight checks (client-level)
110
134
  file '.env', template('.env.tt')
111
135
  end
@@ -2,7 +2,12 @@ module ReactRailsAPI
2
2
  VERSION = {
3
3
  major: 0,
4
4
  minor: 1,
5
- patch: 2,
5
+ patch: 3,
6
6
  meta: nil
7
7
  }.values.reject(&:nil?).map(&:to_s)*?.
8
+
9
+ ENGINE_VERSIONS = {
10
+ node: '^11',
11
+ yarn: '^1.13'
12
+ }
8
13
  end
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.2
4
+ version: 0.1.3
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-13 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -87,7 +87,6 @@ files:
87
87
  - lib/react-rails-api/templates/application.rb.tt
88
88
  - lib/react-rails-api/templates/application_controller.rb.tt
89
89
  - lib/react-rails-api/templates/database.yml.tt
90
- - lib/react-rails-api/templates/package.json.tt
91
90
  - lib/react-rails-api/templates/routes.rb.tt
92
91
  - lib/react-rails-api/templates/start.rake.tt
93
92
  - lib/react-rails-api/version.rb
@@ -1,13 +0,0 @@
1
- {
2
- "name": "api",
3
- "license": "MIT",
4
- "engines": {
5
- "node": "11.11.0",
6
- "yarn": "1.13.0"
7
- },
8
- "scripts": {
9
- "build": "yarn --cwd client install && yarn --cwd client build",
10
- "deploy": "cp -a client/build/. public/",
11
- "postinstall": "yarn build && yarn deploy"
12
- }
13
- }