tractor_beam 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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +127 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/tractor_beam +23 -0
- data/lib/tractor_beam/app_builder.rb +143 -0
- data/lib/tractor_beam/generators/app_generator.rb +115 -0
- data/lib/tractor_beam/version.rb +5 -0
- data/lib/tractor_beam.rb +3 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/tractor_beam_spec.rb +9 -0
- data/templates/Gemfile.erb +35 -0
- data/templates/Procfile +1 -0
- data/templates/Procfile.dev +2 -0
- data/templates/Readme.md.erb +26 -0
- data/templates/bin_setup +30 -0
- data/templates/browserlistrc +1 -0
- data/templates/component_generator +24 -0
- data/templates/eslintrc +27 -0
- data/templates/frontend/init/index.css +1 -0
- data/templates/frontend/init/index.js +1 -0
- data/templates/frontend/packs/application.js +2 -0
- data/templates/stylelintrc +3 -0
- data/templates/tractor_beam_gitignore +18 -0
- data/templates/tractor_beam_layout.html.erb.erb +14 -0
- data/tractor_beam.gemspec +33 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7f49e5bfadcf96d455602acc17ecdde6d7d87504c2dc24c4b34317e5949a4300
|
4
|
+
data.tar.gz: fdbe9a0b243273b8f3e940febe616be01e3f158fe66e744ad06d55d16c879bc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 04ba7de3e527c5122ed8b6e76b1dc8adeac43082cad13db0c4c1b36e79beab5b29f561c52261334b877d8e839faccae87489e628e353a259bf2af7f1c99ee5be
|
7
|
+
data.tar.gz: 5d68257efcb7144cf0386fa25ad07a339afafcf064b77726944d02c20cc1b4f2a112a4c52dc6710f854bf3d6f3d7f9ed4965d3ef5977e1fa9614584975fb5669
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Gabriel Gizotti
|
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,127 @@
|
|
1
|
+
# Tractor Beam
|
2
|
+
|
3
|
+
<img src="https://www.dropbox.com/s/cidq3h3jta78fto/tractor-beam.png?raw=1"
|
4
|
+
data-canonical-src="https://www.dropbox.com/s/cidq3h3jta78fto/tractor-beam.png?raw=1"
|
5
|
+
width=400 />
|
6
|
+
|
7
|
+
## Acknowledgments
|
8
|
+
|
9
|
+
This gem has two major source or inspiration, and I am deeply grateful for the awesome work done by both of them.
|
10
|
+
|
11
|
+
### Evil Martians
|
12
|
+
|
13
|
+
All the frontend setup Tractor Beam does is a representation of the good work put together by the folks at [Evil Martians](https://evilmartians.com), specifically described on their [Modern Front-end in Rails](https://evilmartians.com/chronicles/evil-front-part-1) series of blog posts.
|
14
|
+
|
15
|
+
### thoughtbot
|
16
|
+
|
17
|
+
When looking at how to build a custom rails generator there's no better example than [thoughtbot/suspenders](https://github.com/thoughtbot/suspenders).
|
18
|
+
I have used suspenders as the starting point for Tractor Beam, and ~stole~ borrowed some of its ideas
|
19
|
+
on top of my main goal of building a Rails app with modern frontend tooling.
|
20
|
+
|
21
|
+
## Goals
|
22
|
+
|
23
|
+
The main goal of this gem is to bootstrap a Rails application with all the modern component-based frontend goodness described by Evil Martians [Modern Front-end in Rails](https://evilmartians.com/chronicles/evil-front-part-1) series of blog posts.
|
24
|
+
It also sets up a lot of the go to gems and tools for development in Rails, thus avoiding the initial configuration boilerplate that every new project brings.
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
```
|
29
|
+
gem install tractor_beam
|
30
|
+
```
|
31
|
+
|
32
|
+
Then run:
|
33
|
+
|
34
|
+
```
|
35
|
+
tractor_beam project-name
|
36
|
+
```
|
37
|
+
|
38
|
+
## Versions
|
39
|
+
|
40
|
+
`ruby 2.5.0`
|
41
|
+
`rails ~> 5.1.4`
|
42
|
+
|
43
|
+
## Gemfile
|
44
|
+
|
45
|
+
Tractor Beam copies [Gemfile.erb](https://github.com/gizotti/tractor_beam/blob/master/templates/Gemfile.erb) to project-name/Gemfile.
|
46
|
+
|
47
|
+
It includes application gems:
|
48
|
+
|
49
|
+
* [Postgres](https://github.com/ged/ruby-pg) for access to the Postgres database.
|
50
|
+
* [Puma](https://github.com/puma/puma) to serve HTTP requests.
|
51
|
+
* [Webpacker](https://github.com/rails/webpacker) to Webpack to manage app-like JavaScript modules in Rails.
|
52
|
+
|
53
|
+
Development gems:
|
54
|
+
|
55
|
+
* [pry-rails](https://github.com/rweng/pry-rails) Rails >= 3 pry initializer.
|
56
|
+
* [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug) step-by-step debugging and stack navigation. capabilities to [pry] using [byebug].
|
57
|
+
* [Spring](https://github.com/rails/spring) for fast Rails actions via pre-loading.
|
58
|
+
* [Web Console](https://github.com/rails/web-console) for better debugging via in-browser IRB consoles.
|
59
|
+
|
60
|
+
## Other Sweet Sweet Goodness
|
61
|
+
|
62
|
+
### Component Generator
|
63
|
+
|
64
|
+
```shell
|
65
|
+
rails g component component-name
|
66
|
+
```
|
67
|
+
|
68
|
+
Will generate:
|
69
|
+
|
70
|
+
```shell
|
71
|
+
frontend/components
|
72
|
+
├── component-name
|
73
|
+
│ ├── _component-name.html.erb
|
74
|
+
│ ├── component-name.css
|
75
|
+
│ └── component-name.js
|
76
|
+
```
|
77
|
+
|
78
|
+
### General Linting
|
79
|
+
* [lint-staged](https://github.com/okonet/lint-staged) run linters on git staged files.
|
80
|
+
* [pre-commit](https://github.com/pre-commit/pre-commit) manage multi-language pre-commit hooks.
|
81
|
+
|
82
|
+
### Javascript Linting
|
83
|
+
* [babel-eslint](https://github.com/babel/babel-eslint) ESLint using Babel as the parser.
|
84
|
+
* [eslint](https://github.com/eslint/eslint) identify and report on patterns found in ECMAScript/JavaScript code.
|
85
|
+
* [eslint-config-airbnb-base](https://www.npmjs.com/package/eslint-config-airbnb-base) provides Airbnb's base JS .eslintrc.
|
86
|
+
* [prettier](https://github.com/prettier/prettier) code formatter that enforces a consistent style by parsing your code and re-printing it with its own rules.
|
87
|
+
* [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) turns off all rules that are unnecessary or might conflict with Prettier.
|
88
|
+
* [eslint-import-resolver-webpack](https://www.npmjs.com/package/eslint-import-resolver-webpack) webpack-literate module resolution plugin for eslint-plugin-import.
|
89
|
+
* [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import) support linting of ES2015+ (ES6+) import/export syntax.
|
90
|
+
|
91
|
+
### CSS Linting
|
92
|
+
* [stylelint](https://github.com/stylelint/stylelint) a mighty, modern CSS linter.
|
93
|
+
* [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard) the standard shareable config for stylelint.
|
94
|
+
|
95
|
+
## Todo List
|
96
|
+
- [ ] Write Specs
|
97
|
+
- [ ] Setup rubocop for gem (not generated project)
|
98
|
+
- [ ] Edit Readme.md.erb so it's not just a copy of thoughtbot's template
|
99
|
+
- [ ] jquery-ujs yarn package
|
100
|
+
- [ ] ActionCable yarn package unless skip-actioncable
|
101
|
+
- [ ] Turbolinks yarn package and config unless skip-turbolinks
|
102
|
+
- [ ] Normalize css
|
103
|
+
- [ ] Simple Form
|
104
|
+
- [ ] Testing configuration
|
105
|
+
- [ ] Coverage
|
106
|
+
- [ ] shoulda-matchers
|
107
|
+
- [ ] Factory Bot
|
108
|
+
- [ ] CI configuration
|
109
|
+
- [ ] Dotenv configuration
|
110
|
+
- [ ] Bundler Audit
|
111
|
+
- [ ] Rubocop (Maybe reinteractive-style)
|
112
|
+
- [ ] option to make app Heroku ready
|
113
|
+
|
114
|
+
## Maybe TODO (Stolen ideas from [https://github.com/thoughtbot/suspenders](https://github.com/thoughtbot/suspenders))
|
115
|
+
|
116
|
+
- The ./bin/setup convention for new developer setup
|
117
|
+
- The ./bin/deploy convention for deploying to Heroku
|
118
|
+
- Rails' flashes set up and in application layout
|
119
|
+
- A few nice time formats set up for localization
|
120
|
+
- Rack::Deflater to compress responses with Gzip
|
121
|
+
- A low database connection pool limit
|
122
|
+
- Safe binstubs
|
123
|
+
- t() and l() in specs without prefixing with I18n
|
124
|
+
- An automatically-created SECRET_KEY_BASE environment variable in all environments
|
125
|
+
- Configuration for CircleCI Continuous Integration (tests)
|
126
|
+
- Configuration for Hound Continuous Integration (style)
|
127
|
+
- The analytics adapter Segment (and therefore config for Google Analytics, Intercom, Facebook Ads, Twitter Ads, etc.)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tractor_beam"
|
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
data/bin/tractor_beam
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
|
5
|
+
$LOAD_PATH << source_path
|
6
|
+
|
7
|
+
require 'tractor_beam'
|
8
|
+
|
9
|
+
if ARGV.empty?
|
10
|
+
puts "Please provide a path for the new application"
|
11
|
+
puts
|
12
|
+
puts "See --help for more info"
|
13
|
+
exit 0
|
14
|
+
elsif ['-v', '--version'].include? ARGV[0]
|
15
|
+
puts TractorBeam::VERSION
|
16
|
+
exit 0
|
17
|
+
end
|
18
|
+
|
19
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
20
|
+
TractorBeam::AppGenerator.source_root(templates_root)
|
21
|
+
TractorBeam::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
22
|
+
|
23
|
+
TractorBeam::AppGenerator.start
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module TractorBeam
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
def readme
|
4
|
+
template "README.md.erb", "README.md"
|
5
|
+
end
|
6
|
+
|
7
|
+
def gitignore
|
8
|
+
copy_file "tractor_beam_gitignore", ".gitignore"
|
9
|
+
end
|
10
|
+
|
11
|
+
def gemfile
|
12
|
+
template "Gemfile.erb", "Gemfile"
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_ruby_version
|
16
|
+
create_file '.ruby-version', "#{TractorBeam::RUBY_VERSION}\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
def procfile_dev
|
20
|
+
template "Procfile.dev", "Procfile.dev"
|
21
|
+
end
|
22
|
+
|
23
|
+
def procfile
|
24
|
+
template "Procfile", "Procfile"
|
25
|
+
end
|
26
|
+
|
27
|
+
def provide_setup_script
|
28
|
+
template "bin_setup", "bin/setup", force: true
|
29
|
+
run "chmod a+x bin/setup"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Component Based frontend
|
33
|
+
|
34
|
+
def remove_legacy_assets_folder
|
35
|
+
remove_dir "app/assets"
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup_root_frontend_folder
|
39
|
+
empty_directory "frontend"
|
40
|
+
|
41
|
+
inside "frontend" do
|
42
|
+
directory "packs"
|
43
|
+
directory "init"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_application_layout
|
48
|
+
template 'tractor_beam_layout.html.erb.erb',
|
49
|
+
'app/views/layouts/application.html.erb',
|
50
|
+
force: true
|
51
|
+
end
|
52
|
+
|
53
|
+
def setup_browserlist_rc
|
54
|
+
template "browserlistrc", ".browserlistrc"
|
55
|
+
end
|
56
|
+
|
57
|
+
def customize_webpacker_yml
|
58
|
+
say "Customizing webpacker.yml"
|
59
|
+
|
60
|
+
gsub_file "config/webpacker.yml", "source_path: app/javascript", "source_path: frontend"
|
61
|
+
end
|
62
|
+
|
63
|
+
def prepend_view_path_to_application_controller
|
64
|
+
insert_into_file "app/controllers/application_controller.rb",
|
65
|
+
" prepend_view_path Rails.root.join(\"frontend\")\n",
|
66
|
+
after: "protect_from_forgery with: :exception\n"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Linting
|
70
|
+
|
71
|
+
def setup_js_linter
|
72
|
+
run "yarn add --dev babel-eslint eslint eslint-config-airbnb-base " \
|
73
|
+
"eslint-config-prettier eslint-import-resolver-webpack " \
|
74
|
+
"eslint-plugin-import eslint-plugin-prettier " \
|
75
|
+
"lint-staged pre-commit prettier"
|
76
|
+
|
77
|
+
template "eslintrc", ".eslintrc"
|
78
|
+
end
|
79
|
+
|
80
|
+
def setup_style_linter
|
81
|
+
run "yarn add --dev stylelint stylelint-config-standard"
|
82
|
+
|
83
|
+
template "stylelintrc", ".stylelintrc"
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_scripts_to_package_json
|
87
|
+
scripts = <<-SCRIPTS
|
88
|
+
"scripts": {
|
89
|
+
"lint-staged": "$(yarn bin)/lint-staged"
|
90
|
+
},
|
91
|
+
"lint-staged": {
|
92
|
+
"config/webpack/**/*.js": [
|
93
|
+
"prettier --write",
|
94
|
+
"eslint",
|
95
|
+
"git add"
|
96
|
+
],
|
97
|
+
"frontend/**/*.js": [
|
98
|
+
"prettier --write",
|
99
|
+
"eslint",
|
100
|
+
"git add"
|
101
|
+
],
|
102
|
+
"frontend/**/*.css": [
|
103
|
+
"prettier --write",
|
104
|
+
"stylelint --fix",
|
105
|
+
"git add"
|
106
|
+
]
|
107
|
+
},
|
108
|
+
"pre-commit": [
|
109
|
+
"lint-staged"
|
110
|
+
],
|
111
|
+
SCRIPTS
|
112
|
+
|
113
|
+
insert_into_file "package.json",
|
114
|
+
scripts,
|
115
|
+
after: "},\n"
|
116
|
+
end
|
117
|
+
|
118
|
+
# Generators
|
119
|
+
|
120
|
+
def configure_generators
|
121
|
+
config = <<-RUBY
|
122
|
+
config.generators do |g|
|
123
|
+
g.helper false
|
124
|
+
g.javascripts false
|
125
|
+
g.request_specs false
|
126
|
+
g.routing_specs false
|
127
|
+
g.stylesheets false
|
128
|
+
g.test_framework :rspec
|
129
|
+
g.view_specs false
|
130
|
+
g.channel assets: false
|
131
|
+
end
|
132
|
+
RUBY
|
133
|
+
|
134
|
+
inject_into_class 'config/application.rb', 'Application', config
|
135
|
+
end
|
136
|
+
|
137
|
+
def component_generator
|
138
|
+
empty_directory "lib/generators"
|
139
|
+
|
140
|
+
template "component_generator", "lib/generators/component_generator.rb"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
|
4
|
+
module TractorBeam
|
5
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
+
hide!
|
7
|
+
|
8
|
+
class_option :database, type: :string, aliases: "-d", default: "postgresql",
|
9
|
+
desc: "Configure for selected database (options: #{DATABASES.join("/")})"
|
10
|
+
|
11
|
+
class_option :version, type: :boolean, aliases: "-v", group: :tractor_beam,
|
12
|
+
desc: "Show TractorBeam version number and quit"
|
13
|
+
|
14
|
+
class_option :help, type: :boolean, aliases: '-h', group: :tractor_beam,
|
15
|
+
desc: "Show this help message and quit"
|
16
|
+
|
17
|
+
class_option :path, type: :string, default: nil,
|
18
|
+
desc: "Path to the gem"
|
19
|
+
|
20
|
+
class_option :skip_test, type: :boolean, default: true,
|
21
|
+
desc: "Skip Test Unit"
|
22
|
+
|
23
|
+
class_option :skip_system_test, type: :boolean, default: true,
|
24
|
+
desc: "Skip system test files"
|
25
|
+
|
26
|
+
class_option :skip_turbolinks, type: :boolean, default: true,
|
27
|
+
desc: "Skip turbolinks gem"
|
28
|
+
|
29
|
+
class_option :skip_sprockets, type: :boolean, aliases: "-S",
|
30
|
+
default: true, desc: "Skip Sprockets files"
|
31
|
+
|
32
|
+
class_option :skip_coffee, type: :boolean, default: true,
|
33
|
+
desc: "Don't use CoffeeScript"
|
34
|
+
|
35
|
+
class_option :webpack, type: :string, default: "webpack",
|
36
|
+
desc: "Preconfigure for app-like JavaScript with Webpack (options: #{WEBPACKS.join('/')})"
|
37
|
+
|
38
|
+
def finish_template
|
39
|
+
invoke :beam_customizations
|
40
|
+
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def beam_customizations
|
45
|
+
build :set_ruby_version
|
46
|
+
|
47
|
+
invoke :setup_development_environment
|
48
|
+
invoke :setup_production_environment
|
49
|
+
invoke :run_bundle
|
50
|
+
invoke :run_webpack
|
51
|
+
invoke :setup_component_based_frontend
|
52
|
+
invoke :setup_linters
|
53
|
+
invoke :generate_spring_binstubs
|
54
|
+
invoke :git_first_commit
|
55
|
+
invoke :outro
|
56
|
+
end
|
57
|
+
|
58
|
+
def setup_component_based_frontend
|
59
|
+
say "Setting modern frontend architecture"
|
60
|
+
|
61
|
+
build :remove_legacy_assets_folder
|
62
|
+
build :setup_root_frontend_folder
|
63
|
+
build :create_application_layout
|
64
|
+
build :setup_browserlist_rc
|
65
|
+
build :customize_webpacker_yml
|
66
|
+
build :prepend_view_path_to_application_controller
|
67
|
+
end
|
68
|
+
|
69
|
+
def setup_linters
|
70
|
+
say "Setting up linters"
|
71
|
+
|
72
|
+
build :setup_js_linter
|
73
|
+
build :setup_style_linter
|
74
|
+
build :add_scripts_to_package_json
|
75
|
+
end
|
76
|
+
|
77
|
+
def setup_development_environment
|
78
|
+
say "Setting up development environment"
|
79
|
+
|
80
|
+
build :configure_generators
|
81
|
+
build :component_generator
|
82
|
+
build :procfile_dev
|
83
|
+
build :provide_setup_script
|
84
|
+
end
|
85
|
+
|
86
|
+
def setup_production_environment
|
87
|
+
say "Setting up production environment"
|
88
|
+
|
89
|
+
build :procfile
|
90
|
+
end
|
91
|
+
|
92
|
+
def git_first_commit
|
93
|
+
say "Commiting skeleton app to git"
|
94
|
+
|
95
|
+
run("git add . && git commit -m 'first commit'")
|
96
|
+
end
|
97
|
+
|
98
|
+
def outro
|
99
|
+
outro_text = <<-OUTRO
|
100
|
+
|
101
|
+
========================
|
102
|
+
= Abduction complete!! =
|
103
|
+
========================
|
104
|
+
OUTRO
|
105
|
+
|
106
|
+
say outro_text, :blue
|
107
|
+
end
|
108
|
+
|
109
|
+
protected
|
110
|
+
|
111
|
+
def get_builder_class
|
112
|
+
TractorBeam::AppBuilder
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/tractor_beam.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "tractor_beam"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
git_source(:github) do |repo_name|
|
4
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
5
|
+
"https://github.com/#{repo_name}.git"
|
6
|
+
end
|
7
|
+
|
8
|
+
ruby "<%= TractorBeam::RUBY_VERSION %>"
|
9
|
+
|
10
|
+
gem 'pg', "~> 0.21"
|
11
|
+
gem 'puma'
|
12
|
+
gem "rails", "<%= TractorBeam::RAILS_VERSION %>"
|
13
|
+
gem 'webpacker'
|
14
|
+
|
15
|
+
group :development, :test do
|
16
|
+
# gem "bundler-audit", ">= 0.5.0", require: false
|
17
|
+
# gem "dotenv-rails"
|
18
|
+
# gem "factory_bot_rails"
|
19
|
+
gem "pry-byebug"
|
20
|
+
gem "pry-rails"
|
21
|
+
# gem "rspec-rails", "~> 3.6"
|
22
|
+
end
|
23
|
+
|
24
|
+
group :development do
|
25
|
+
gem 'web-console', '>= 3.3.0'
|
26
|
+
gem 'listen', '>= 3.0.5', '< 3.2'
|
27
|
+
gem 'spring'
|
28
|
+
gem 'spring-watcher-listen', '~> 2.0.0'
|
29
|
+
gem "spring-commands-rspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
group :test do
|
33
|
+
# gem "shoulda-matchers"
|
34
|
+
# gem "simplecov", require: false
|
35
|
+
end
|
data/templates/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
web: bin/rails server
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# <%= app_name.humanize %>
|
2
|
+
|
3
|
+
## Getting Started
|
4
|
+
|
5
|
+
After you have cloned this repo, run this setup script to set up your machine
|
6
|
+
with the necessary dependencies to run and test this app:
|
7
|
+
|
8
|
+
% ./bin/setup
|
9
|
+
|
10
|
+
It assumes you have a machine equipped with Ruby, Postgres, etc.
|
11
|
+
|
12
|
+
## Generating Components
|
13
|
+
|
14
|
+
```shell
|
15
|
+
rails g component component-name
|
16
|
+
```
|
17
|
+
|
18
|
+
Will generate:
|
19
|
+
|
20
|
+
```shell
|
21
|
+
frontend/components
|
22
|
+
├── component-name
|
23
|
+
│ ├── _component-name.html.erb
|
24
|
+
│ ├── component-name.css
|
25
|
+
│ └── component-name.js
|
26
|
+
```
|
data/templates/bin_setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a starting point to setup your application.
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
puts "\n== Preparing database =="
|
22
|
+
system! 'bin/rails db:create'
|
23
|
+
system! 'bin/rails db:migrate'
|
24
|
+
|
25
|
+
puts "\n== Removing old logs and tempfiles =="
|
26
|
+
system! 'bin/rails log:clear tmp:clear'
|
27
|
+
|
28
|
+
puts "\n== Restarting application server =="
|
29
|
+
system! 'bin/rails restart'
|
30
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
> %1
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class ComponentGenerator < Rails::Generators::Base
|
2
|
+
argument :component_name, required: true, desc: "Component name, e.g: button"
|
3
|
+
|
4
|
+
def create_view_file
|
5
|
+
create_file "#{component_path}/_#{component_name}.html.erb"
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_css_file
|
9
|
+
create_file "#{component_path}/#{component_name}.css"
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_js_file
|
13
|
+
create_file "#{component_path}/#{component_name}.js" do
|
14
|
+
# require component's CSS inside JS automatically
|
15
|
+
"import \"./#{component_name}.css\";\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def component_path
|
22
|
+
"frontend/components/#{component_name}"
|
23
|
+
end
|
24
|
+
end
|
data/templates/eslintrc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"extends": ["eslint-config-airbnb-base", "prettier"],
|
3
|
+
|
4
|
+
"plugins": ["prettier"],
|
5
|
+
|
6
|
+
"env": {
|
7
|
+
"browser": true
|
8
|
+
},
|
9
|
+
|
10
|
+
"rules": {
|
11
|
+
"prettier/prettier": "error"
|
12
|
+
},
|
13
|
+
|
14
|
+
"parser": "babel-eslint",
|
15
|
+
|
16
|
+
"settings": {
|
17
|
+
"import/resolver": {
|
18
|
+
"webpack": {
|
19
|
+
"config": {
|
20
|
+
"resolve": {
|
21
|
+
"modules": ["frontend", "node_modules"]
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
/* include any global css needed in initialization here */
|
@@ -0,0 +1 @@
|
|
1
|
+
// Insert any global javascript needed on initialization here
|
@@ -0,0 +1,18 @@
|
|
1
|
+
!.keep
|
2
|
+
*.DS_Store
|
3
|
+
*.swo
|
4
|
+
*.swp
|
5
|
+
.byebug_history
|
6
|
+
/.bundle
|
7
|
+
/.env.local
|
8
|
+
/coverage/*
|
9
|
+
/db/*.sqlite3
|
10
|
+
/db/*.sqlite3-journal
|
11
|
+
/log/*
|
12
|
+
/node_modules
|
13
|
+
/public/assets
|
14
|
+
/public/packs
|
15
|
+
/public/system
|
16
|
+
/tags
|
17
|
+
/tmp/*
|
18
|
+
/yarn-error.log
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
require "tractor_beam/version"
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.required_ruby_version = ">= #{TractorBeam::RUBY_VERSION}"
|
7
|
+
spec.required_rubygems_version = ">= 2.7.4"
|
8
|
+
spec.authors = ["Gabriel Gizotti"]
|
9
|
+
spec.email = ["gabriel@gizotti.com"]
|
10
|
+
spec.date = Date.today.strftime('%Y-%m-%d')
|
11
|
+
spec.name = "tractor_beam"
|
12
|
+
spec.version = TractorBeam::VERSION
|
13
|
+
|
14
|
+
spec.description = <<-HERE
|
15
|
+
Tractor Beam is a base Rails project with all the modern javascript goodness
|
16
|
+
described by https://evilmartians.com/chronicles/evil-front-part-1.
|
17
|
+
Use it to get your rails app up and running with webpacker and a component
|
18
|
+
based infrastructure for your frontend.
|
19
|
+
HERE
|
20
|
+
|
21
|
+
spec.summary = "Generate a Rails app using modern javascript tooling."
|
22
|
+
spec.homepage = "https://github.com/gizotti/tractor_beam"
|
23
|
+
spec.license = "MIT"
|
24
|
+
spec.files = `git ls-files`.split("\n")
|
25
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
|
27
|
+
spec.executables = ["tractor_beam"]
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency 'rails', TractorBeam::RAILS_VERSION
|
31
|
+
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tractor_beam
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriel Gizotti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-12 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.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
41
|
+
description: |
|
42
|
+
Tractor Beam is a base Rails project with all the modern javascript goodness
|
43
|
+
described by https://evilmartians.com/chronicles/evil-front-part-1.
|
44
|
+
Use it to get your rails app up and running with webpacker and a component
|
45
|
+
based infrastructure for your frontend.
|
46
|
+
email:
|
47
|
+
- gabriel@gizotti.com
|
48
|
+
executables:
|
49
|
+
- tractor_beam
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- ".gitignore"
|
54
|
+
- ".rspec"
|
55
|
+
- ".ruby-version"
|
56
|
+
- ".travis.yml"
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE.txt
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- bin/console
|
62
|
+
- bin/setup
|
63
|
+
- bin/tractor_beam
|
64
|
+
- lib/tractor_beam.rb
|
65
|
+
- lib/tractor_beam/app_builder.rb
|
66
|
+
- lib/tractor_beam/generators/app_generator.rb
|
67
|
+
- lib/tractor_beam/version.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/tractor_beam_spec.rb
|
70
|
+
- templates/Gemfile.erb
|
71
|
+
- templates/Procfile
|
72
|
+
- templates/Procfile.dev
|
73
|
+
- templates/Readme.md.erb
|
74
|
+
- templates/bin_setup
|
75
|
+
- templates/browserlistrc
|
76
|
+
- templates/component_generator
|
77
|
+
- templates/eslintrc
|
78
|
+
- templates/frontend/init/index.css
|
79
|
+
- templates/frontend/init/index.js
|
80
|
+
- templates/frontend/packs/application.js
|
81
|
+
- templates/stylelintrc
|
82
|
+
- templates/tractor_beam_gitignore
|
83
|
+
- templates/tractor_beam_layout.html.erb.erb
|
84
|
+
- tractor_beam.gemspec
|
85
|
+
homepage: https://github.com/gizotti/tractor_beam
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.5.0
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.7.4
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.7.4
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Generate a Rails app using modern javascript tooling.
|
109
|
+
test_files:
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/tractor_beam_spec.rb
|