revelry_generate 0.3.10 → 0.4.0

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
  SHA1:
3
- metadata.gz: fd657d121d5a51ec217bbbc3e909cba65df1c98f
4
- data.tar.gz: fb8ce5f5c39820e78a6865830e4b78729aaddc3a
3
+ metadata.gz: 2e7ec78de327d2790ab466f0e9e5b6dfac291e8a
4
+ data.tar.gz: e2fc39215f318072c55eff3006d01d414578e64e
5
5
  SHA512:
6
- metadata.gz: c841ea1129b5df7ad06279193093e9f0f7130e8a96f3649b147b42756e3f178414631fc75c495e8be2e64c3d7d9a4eb60caa2870654dcc889863c9c651e3c914
7
- data.tar.gz: be9e97396ea28d57986df876995139063568954f3a1abc5baab066ceb1004299ab5a627ad44869de49e88173ab5c33a1c27f6a1199097a33c43c90763732302a
6
+ metadata.gz: 3e534677cbfa766d2d8dca769b8cf27d73ae816802e11fe7bbeecbc3b9c988fd1a2f7f909b533a3543ba75c60ada4dfb42cf42184f01aa02953752e6c1b3373c
7
+ data.tar.gz: c07de3837f37699eb8203338f7c4a4fb6f642a3dd027cd1d69e77983d05422e78163e93e5ece107e5436df0320e53b1e15dbc01add79c0706b247a42fd7b664d
data/README.md CHANGED
@@ -6,7 +6,7 @@ Revelry 2016 Name TBD stack.
6
6
  ## Using
7
7
 
8
8
  ```
9
- rails new app_name -m template.rb
9
+ rails new app_name -m template.rb -T -d postgresql
10
10
  ```
11
11
 
12
12
  or
@@ -18,27 +18,18 @@ bin/rake rails:template LOCATION=template.rb
18
18
  This will generate an app using the default skeleton. The skeleton will give you
19
19
  further instructions from there.
20
20
 
21
- ## node-base (default) skeleton
21
+ ## slush (default) skeleton
22
22
 
23
- This provides a minimal skeleton for rails with rails-render-service and the
23
+ This provides a skeleton for rails with rails_render_service and the
24
24
  revelry framework. After creating a new app with the template (see above), you
25
25
  can:
26
26
 
27
- ### Start the rails server
27
+ ### Start the servers
28
28
 
29
29
  ```
30
- rails s
30
+ npm run dev
31
31
  ```
32
32
 
33
- ### Start the development render server
34
-
35
- ```
36
- npm run devserver
37
- ```
38
-
39
- (this will run the render server in node, and rebuild client & server-side JS
40
- and scss)
41
-
42
33
  ### Scaffold a new resource
43
34
 
44
35
  Just do:
@@ -44,7 +44,7 @@ module RevelryGenerate
44
44
  end
45
45
 
46
46
  def try_after_hook
47
- hook_path = File.join(gem_root, 'skeletons', 'node-base', '__generators__', 'post_skeleton.rb')
47
+ hook_path = File.join(gem_root, 'skeletons', ENV['SKELETON'] || 'slush', '__generators__', 'post_skeleton.rb')
48
48
 
49
49
  return unless File.exist? hook_path
50
50
  puts "rake rails:template LOCATION=#{hook_path}"
@@ -1,5 +1,4 @@
1
1
  require 'rails'
2
- require_relative './rails/generators/react_scaffold/react_scaffold_generator'
3
2
  require_relative './rails/generators/jbuilder_props/jbuilder_props_generator'
4
3
 
5
4
  module RevelryGenerate
data/scripts/skeleton.js CHANGED
@@ -6,7 +6,7 @@ var inquirer = require('inquirer');
6
6
  var spawnSync = require('child_process').spawn;
7
7
 
8
8
 
9
- var skeletonPath = Path.resolve(__dirname, '../skeletons/node-base');
9
+ var skeletonPath = Path.resolve(__dirname, '../skeletons/' + (process.env.SKELETON || 'slush'));
10
10
 
11
11
  console.log(__dirname);
12
12
  var needsConfirmationItems = [];
@@ -0,0 +1 @@
1
+ web: npm start
@@ -0,0 +1,181 @@
1
+ # Set the latest installed node version in nodenv as the version
2
+ node_version = `nodenv versions`.split.last
3
+
4
+ # Bootstrap a render server node app
5
+ x = system(
6
+ <<-SH
7
+ nodenv local #{node_version} &&
8
+ npm install -g slush revelrylabs/slush-revelry &&
9
+ npm install &&
10
+ slush &&
11
+ slush revelry:new render-server &&
12
+ cd render-server &&
13
+ npm install &&
14
+ npm install --save morgan &&
15
+ cd -
16
+ SH
17
+ ) || fail('slush template installation failed')
18
+
19
+ # Link the build directory of webpack to public (so we can serve the assets through Rails)
20
+ system('ln -s ../render-server/dist/public/css public/css')
21
+ system('ln -s ../render-server/dist/public/js public/js')
22
+ system('ln -s ../render-server/dist/public/fonts public/fonts')
23
+
24
+ # Set up a suitable gitignore for the render server directory
25
+ system('curl https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore >> render-server/.gitignore')
26
+ system('curl https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore > render-server/.gitignore')
27
+
28
+ # Add the build directory
29
+ append_to_file 'render-server/.gitignore', <<-GITIGNORE
30
+
31
+ dist/
32
+ GITIGNORE
33
+
34
+ # Also add Node stuff to the root .gitignore since we have node_modules that live off of the rails root too (for scripts)
35
+ system('curl https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore >> .gitignore')
36
+ system('curl https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore >> .gitignore')
37
+
38
+ # Amend the generated server.js to be compatible with rails_render_service
39
+ create_file 'render-server/src/js/server.js', <<-JS
40
+ import http from 'http'
41
+ import express from 'express'
42
+ import fs from 'fs'
43
+ import bodyParser from 'body-parser'
44
+ import cors from 'cors'
45
+ import {renderJson, renderHtml} from 'setup/renderServer'
46
+ import router from 'setup/router'
47
+ import renderServiceRouter from 'setup/renderServiceRouter'
48
+ import {NODE_ENV, PORT} from 'config/server'
49
+
50
+ import morgan from 'morgan'
51
+
52
+ const app = express()
53
+
54
+ // Express configuration and middlewares
55
+ if (NODE_ENV !== 'production') {
56
+ app.use(cors())
57
+ }
58
+ app.use(express.static('dist/public'))
59
+ app.use(bodyParser.json())
60
+ app.use(bodyParser.urlencoded({extended: true}))
61
+ app.use(morgan('combined'))
62
+
63
+ app.use(renderHtml)
64
+ app.use('*', renderServiceRouter)
65
+
66
+ // Turn it into an HTTP server
67
+ const server = http.createServer(app)
68
+
69
+ server.on('error', (e) => {
70
+ if (e.code == 'EADDRINUSE') {
71
+ fs.unlinkSync(PORT);
72
+ server.listen(PORT);
73
+ }
74
+ })
75
+
76
+ server.listen(PORT)
77
+ // eslint-disable-next-line no-console
78
+ console.log(`Server is listening on ${PORT}`)
79
+ JS
80
+
81
+ # Amend the generated renderServiceRouter.js to be compatible with rails_render_service
82
+ create_file 'render-server/src/js/setup/renderServiceRouter.js', <<-JS
83
+ import {Router} from 'express'
84
+ import {get as getView} from './autoload/views'
85
+ const router = new Router()
86
+
87
+ router.post('*', (req, res) => {
88
+ const {name, data} = req.body
89
+
90
+ res.render(name, data || {})
91
+ })
92
+
93
+ router.get('*', (req, res) => {
94
+ const name = req.originalUrl.slice(1)
95
+ const data = req.body
96
+
97
+ try {
98
+ const _view = getView(name)
99
+ res.status(200).send('Ok')
100
+ } catch(e) {
101
+ if(e.toString().indexOf('Cannot find module')) {
102
+ res.status(404).send('Not found')
103
+ } else {
104
+ throw e;
105
+ }
106
+ }
107
+ })
108
+
109
+ export default router
110
+ JS
111
+
112
+ # Change the local asset prefix to work with static assets served out of rails
113
+ create_file 'render-server/gulpfile.js', <<-JS
114
+ const gulp = require('gulp')
115
+ const createTasks = require('our-gulp')
116
+
117
+ const isProd = process.env.NODE_ENV === 'production'
118
+
119
+ const CDN_ASSET_PREFIX = ''
120
+ const LOCAL_ASSET_PREFIX = ''
121
+
122
+ const assetUrlPrefix = isProd ? CDN_ASSET_PREFIX : LOCAL_ASSET_PREFIX
123
+
124
+ createTasks(gulp, {
125
+ assetUrlPrefix: assetUrlPrefix,
126
+ basePath: __dirname + '/',
127
+ sassIncludePaths: [
128
+ 'src/css',
129
+ 'node_modules/foundation-sites/scss',
130
+ 'node_modules/revelry-components/scss',
131
+ ]
132
+ })
133
+ JS
134
+
135
+ inject_into_file 'spec/rails_helper.rb', after: 'RSpec.configure do |config|' do
136
+ <<-'RUBY'
137
+
138
+ config.render_views
139
+
140
+ config.before(:suite) do
141
+ ENV['RENDER_SERVICE_SOCKET'] = 'tmp/testRender.sock'
142
+ `(cd render-server; npm run build)`
143
+ @pid = spawn('(cd render-server; npm run servetest)')
144
+ # Force us to not continue until render wakes up
145
+ RailsRenderService::Renderer.has_template 'foo'
146
+ end
147
+
148
+ config.after(:suite) do
149
+ Process.kill("TERM", @pid)
150
+ end
151
+ RUBY
152
+ end
153
+
154
+ inject_into_file 'render-server/package.json', after: '"scripts": {' do
155
+ <<-'JSON'
156
+
157
+ "postinstall": "(cd render-server; npm install && npm run build)",
158
+ JSON
159
+ end
160
+
161
+ create_file 'README.md'
162
+ append_to_file 'README.md', <<-MD
163
+ ## Starting render server
164
+
165
+ To start the render server, do:
166
+
167
+ ```
168
+ npm run dev
169
+ ```
170
+
171
+ ## Deploy to Heroku
172
+
173
+ Update this code block with the correct template url and then un-codify it. That'll
174
+ make you a heroku button to deploy this app:
175
+
176
+ ```
177
+ [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/heroku/node-js-sample)
178
+ ```
179
+ MD
180
+
181
+ system('cat README.md')
@@ -0,0 +1,48 @@
1
+ {
2
+ "addons": [
3
+ {
4
+ "plan": "heroku-postgresql:hobby-basic"
5
+ },
6
+ {
7
+ "plan": "papertrail:choklad"
8
+ },
9
+ {
10
+ "plan": "rollbar:free"
11
+ },
12
+ {
13
+ "plan": "scheduler:standard"
14
+ }
15
+ ],
16
+ "buildpacks": [
17
+ {
18
+ "url": "heroku/nodejs"
19
+ },
20
+ {
21
+ "url": "heroku/ruby"
22
+ }
23
+ ],
24
+ "env": {
25
+ "DEVISE_SECRET_KEY": {
26
+ "generator": "secret"
27
+ },
28
+ "GITHUB_TOKEN": {
29
+ "required": true,
30
+ "value": "CHANGE ME"
31
+ },
32
+ "RAILS_ENV": {
33
+ "value": "production"
34
+ },
35
+ "RAILS_SERVE_STATIC_FILES": {
36
+ "value": "enabled"
37
+ },
38
+ "SECRET_KEY_BASE": {
39
+ "generator": "secret"
40
+ }
41
+ },
42
+ "formation": {
43
+ "web": {
44
+ "quantity": 1,
45
+ "size": "standard-1x"
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,17 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/erb/scaffold/scaffold_generator'
3
+
4
+ module Rails
5
+ module Generators
6
+ class ReactScaffoldGenerator < Erb::Generators::ScaffoldGenerator
7
+ def copy_view_files
8
+ Dir.chdir('render-server') do
9
+ system "slush revelry:module #{controller_class_name.pluralize.dasherize.downcase}"
10
+ end
11
+ end
12
+
13
+ hook_for :form_builder, :as => :scaffold
14
+ hook_for :jbuilder_props, default: true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "railsrenderexample",
3
+ "version": "1.0.0",
4
+ "description": "== README",
5
+ "main": "build/server.js",
6
+ "directories": {
7
+ "test": "test"
8
+ },
9
+ "scripts": {
10
+ "heroku-prebuild": "npm i heroku-private-modules && heroku-private-modules && (cd render-server && heroku-private-modules)",
11
+ "start": "NODE_ENV=$RAILS_ENV concurrently -p \"{command}\" -l 20 \"npm run rails\" \"npm run node\"",
12
+ "rails": "RENDER_SERVICE_SOCKET=./tmp/render.sock bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}",
13
+ "node": "(cd render-server; PORT=../tmp/render.sock node_modules/.bin/nodemon dist/server.js)",
14
+ "nodedev": "(cd render-server; PORT=../tmp/render.sock npm run dev)",
15
+ "dev": "NODE_ENV=$RAILS_ENV concurrently -p \"{command}\" -l 20 \"npm run rails\" \"npm run nodedev\""
16
+ },
17
+ "author": "",
18
+ "license": "UNLICENSED",
19
+ "devDependencies": {
20
+ "nodemon": "^1.9.1"
21
+ },
22
+ "dependencies": {
23
+ "concurrently": "^3.4.0",
24
+ "slush": "^1.1.1",
25
+ "slush-revelry": "github:revelrylabs/slush-revelry"
26
+ }
27
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revelry_generate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Prehn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email:
@@ -24,12 +24,6 @@ files:
24
24
  - lib/rails/generators/jbuilder_props/templates/index.json.jbuilder
25
25
  - lib/rails/generators/jbuilder_props/templates/new.json.jbuilder
26
26
  - lib/rails/generators/jbuilder_props/templates/show.json.jbuilder
27
- - lib/rails/generators/react_scaffold/react_scaffold_generator.rb
28
- - lib/rails/generators/react_scaffold/templates/edit.js.erb
29
- - lib/rails/generators/react_scaffold/templates/form.js.erb
30
- - lib/rails/generators/react_scaffold/templates/index.js.erb
31
- - lib/rails/generators/react_scaffold/templates/new.js.erb
32
- - lib/rails/generators/react_scaffold/templates/show.js.erb
33
27
  - lib/rails/generators/revelry_generate/skeleton_generator.rb
34
28
  - lib/revelry_generate.rb
35
29
  - package.json
@@ -41,6 +35,12 @@ files:
41
35
  - skeletons/node-base/__generators__/post_scaffold.js
42
36
  - skeletons/node-base/__generators__/post_skeleton.rb
43
37
  - skeletons/node-base/build/keep
38
+ - skeletons/node-base/config/initializers/scaffold.rb
39
+ - skeletons/node-base/config/initializers/templates/edit.js.erb
40
+ - skeletons/node-base/config/initializers/templates/form.js.erb
41
+ - skeletons/node-base/config/initializers/templates/index.js.erb
42
+ - skeletons/node-base/config/initializers/templates/new.js.erb
43
+ - skeletons/node-base/config/initializers/templates/show.js.erb
44
44
  - skeletons/node-base/package.json
45
45
  - skeletons/node-base/scripts/dev-server.sh
46
46
  - skeletons/node-base/scripts/js-builder.js
@@ -54,6 +54,11 @@ files:
54
54
  - skeletons/node-base/src/components/base.js
55
55
  - skeletons/node-base/src/server.js
56
56
  - skeletons/node-base/src/views.js
57
+ - skeletons/slush/Procfile
58
+ - skeletons/slush/__generators__/post_skeleton.rb
59
+ - skeletons/slush/app.json
60
+ - skeletons/slush/config/initializers/scaffold.rb
61
+ - skeletons/slush/package.json
57
62
  homepage: https://github.com/revelrylabs/generate.git
58
63
  licenses:
59
64
  - MIT
@@ -74,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
79
  version: '0'
75
80
  requirements: []
76
81
  rubyforge_project:
77
- rubygems_version: 2.4.5.1
82
+ rubygems_version: 2.5.1
78
83
  signing_key:
79
84
  specification_version: 4
80
85
  summary: ''