tractor_beam 0.1.1 → 0.1.2
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/.rubocop.yml +50 -0
- data/.travis.yml +24 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -1
- data/README.md +3 -5
- data/Rakefile +3 -1
- data/USAGE +14 -0
- data/bin/console +1 -0
- data/bin/tractor_beam +6 -4
- data/lib/tractor_beam/app_builder.rb +39 -10
- data/lib/tractor_beam/generators/app_generator.rb +31 -18
- data/lib/tractor_beam/version.rb +5 -3
- data/lib/tractor_beam.rb +2 -0
- data/spec/features/cli_help_spec.rb +38 -0
- data/spec/features/new_project_spec.rb +203 -0
- data/spec/spec_helper.rb +18 -5
- data/spec/support/tractor_beam.rb +71 -0
- data/templates/bin_setup +10 -10
- data/templates/cable_js +14 -0
- data/templates/frontend/init/index.js.erb +11 -0
- data/tractor_beam.gemspec +11 -6
- metadata +56 -6
- data/spec/tractor_beam_spec.rb +0 -9
- data/templates/frontend/init/index.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75dd77823d41fe116f0fc1b2d8285e150f1e1f772d1d74c520241f288ef82ea4
|
4
|
+
data.tar.gz: fd19dea1a3946b93220ab38e6eafba1f280fc73a5461ff3e419af08d334eae23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59513cd6a6ffbe68e575a5418aa0a9ff605bc1a7ab2cdf259e8766b7b572a8fe1ba7c6af0a4d18514cfe7925a8caf0ca061bf4c57fa591a08f4926c04e38c6a0
|
7
|
+
data.tar.gz: 88b2da410bad5e396f0faa3e0d347e78598edd48f1b4ac8dc8da1ab05c987a26758a95865ea635d854b8974902c255b49ddadc8e51b5d6c56683cebd6dcfaecc
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- templates/**/*
|
4
|
+
|
5
|
+
Style/StringLiterals:
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Metrics/LineLength:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Layout/AlignParameters:
|
12
|
+
EnforcedStyle: with_first_parameter
|
13
|
+
|
14
|
+
Layout/IndentHeredoc:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/ClassLength:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Naming/AccessorMethodName:
|
24
|
+
Exclude:
|
25
|
+
- 'lib/tractor_beam/generators/app_generator.rb'
|
26
|
+
|
27
|
+
Style/Documentation:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Metrics/LineLength:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Metrics/BlockLength:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/PercentLiteralDelimiters:
|
37
|
+
Enabled: true
|
38
|
+
PreferredDelimiters:
|
39
|
+
"%": "()"
|
40
|
+
"%i": "()"
|
41
|
+
"%q": "()"
|
42
|
+
"%Q": "()"
|
43
|
+
"%r": "{}"
|
44
|
+
"%s": "()"
|
45
|
+
"%w": "()"
|
46
|
+
"%W": "()"
|
47
|
+
"%x": "()"
|
48
|
+
|
49
|
+
Style/TrailingCommaInArguments:
|
50
|
+
EnforcedStyleForMultiline: comma
|
data/.travis.yml
CHANGED
@@ -1,5 +1,25 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
|
-
rvm:
|
4
|
-
|
5
|
-
|
2
|
+
rvm: 2.5.0
|
3
|
+
cache: bundler
|
4
|
+
sudo: false
|
5
|
+
before_install:
|
6
|
+
- "echo '--colour' > ~/.rspec"
|
7
|
+
- git config --global user.name 'Travis CI'
|
8
|
+
- git config --global user.email 'travis-ci@example.com'
|
9
|
+
- gem update --system
|
10
|
+
-
|
11
|
+
install: bundle install
|
12
|
+
|
13
|
+
env:
|
14
|
+
global:
|
15
|
+
- CC_TEST_REPORTER_ID="09ed0410f3fbea5adfde57a2176ee68472404421c98b17ea57139beaa425308b"
|
16
|
+
|
17
|
+
before_script:
|
18
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
19
|
+
- chmod +x ./cc-test-reporter
|
20
|
+
- ./cc-test-reporter before-build
|
21
|
+
|
22
|
+
script:
|
23
|
+
- bundle exec rubocop
|
24
|
+
- bundle exec rspec
|
25
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Change log
|
2
|
+
|
3
|
+
## 0.1.2 (2018-01-017)
|
4
|
+
|
5
|
+
* Add rubocop development dependency
|
6
|
+
* Setup project on Travis CI
|
7
|
+
* Ensure jquery-ujs yarn package is installed
|
8
|
+
* Ensure actioncable yarn package is install unless `skip_action_cable` option is true
|
9
|
+
* Ensure turbolinks yarn package is install unless `skip_turbolinks` option is true
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in tractor_beam.gemspec
|
6
8
|
gemspec
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://codeclimate.com/github/gizotti/tractor_beam/maintainability)
|
2
|
+
[](https://codeclimate.com/github/gizotti/tractor_beam/test_coverage)
|
3
|
+
|
1
4
|
# Tractor Beam
|
2
5
|
|
3
6
|
<img src="https://www.dropbox.com/s/cidq3h3jta78fto/tractor-beam.png?raw=1"
|
@@ -94,11 +97,6 @@ frontend/components
|
|
94
97
|
|
95
98
|
## Todo List
|
96
99
|
- [ ] 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
100
|
- [ ] Normalize css
|
103
101
|
- [ ] Simple Form
|
104
102
|
- [ ] Testing configuration
|
data/Rakefile
CHANGED
data/USAGE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Description:
|
2
|
+
Suspenders is a Rails template with with defaults
|
3
|
+
for component based frontend, as described by
|
4
|
+
https://evilmartians.com/chronicles/evil-front-part-1
|
5
|
+
|
6
|
+
For full details on the changes we've made compared to
|
7
|
+
a vanilla Rails app, check our GitHub project:
|
8
|
+
https://github.com/gizotti/tractor_beam
|
9
|
+
|
10
|
+
Example:
|
11
|
+
tractor_beam ~/Code/weblog
|
12
|
+
|
13
|
+
This generates a Rails installation in ~/Code/weblog configured
|
14
|
+
with our preferred defaults.
|
data/bin/console
CHANGED
data/bin/tractor_beam
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
require "pathname"
|
5
|
+
|
6
|
+
source_path = (Pathname.new(__FILE__).dirname + "../lib").expand_path
|
5
7
|
$LOAD_PATH << source_path
|
6
8
|
|
7
|
-
require
|
9
|
+
require "tractor_beam"
|
8
10
|
|
9
11
|
if ARGV.empty?
|
10
12
|
puts "Please provide a path for the new application"
|
11
13
|
puts
|
12
14
|
puts "See --help for more info"
|
13
15
|
exit 0
|
14
|
-
elsif [
|
16
|
+
elsif ["-v", "--version"].include? ARGV[0]
|
15
17
|
puts TractorBeam::VERSION
|
16
18
|
exit 0
|
17
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TractorBeam
|
2
4
|
class AppBuilder < Rails::AppBuilder
|
3
5
|
def readme
|
@@ -13,7 +15,7 @@ module TractorBeam
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def set_ruby_version
|
16
|
-
create_file
|
18
|
+
create_file ".ruby-version", "#{TractorBeam::RUBY_VERSION}\n"
|
17
19
|
end
|
18
20
|
|
19
21
|
def procfile_dev
|
@@ -40,14 +42,17 @@ module TractorBeam
|
|
40
42
|
|
41
43
|
inside "frontend" do
|
42
44
|
directory "packs"
|
43
|
-
|
45
|
+
empty_directory "init"
|
44
46
|
end
|
47
|
+
|
48
|
+
template "frontend/init/index.css", "frontend/init/index.css", force: true
|
49
|
+
template "frontend/init/index.js.erb", "frontend/init/index.js", force: true
|
45
50
|
end
|
46
51
|
|
47
52
|
def create_application_layout
|
48
|
-
template
|
49
|
-
|
50
|
-
|
53
|
+
template "tractor_beam_layout.html.erb.erb",
|
54
|
+
"app/views/layouts/application.html.erb",
|
55
|
+
force: true
|
51
56
|
end
|
52
57
|
|
53
58
|
def setup_browserlist_rc
|
@@ -62,8 +67,8 @@ module TractorBeam
|
|
62
67
|
|
63
68
|
def prepend_view_path_to_application_controller
|
64
69
|
insert_into_file "app/controllers/application_controller.rb",
|
65
|
-
|
66
|
-
|
70
|
+
" prepend_view_path Rails.root.join(\"frontend\")\n",
|
71
|
+
after: "protect_from_forgery with: :exception\n"
|
67
72
|
end
|
68
73
|
|
69
74
|
# Linting
|
@@ -111,8 +116,8 @@ module TractorBeam
|
|
111
116
|
SCRIPTS
|
112
117
|
|
113
118
|
insert_into_file "package.json",
|
114
|
-
|
115
|
-
|
119
|
+
scripts,
|
120
|
+
after: "},\n"
|
116
121
|
end
|
117
122
|
|
118
123
|
# Generators
|
@@ -131,7 +136,7 @@ module TractorBeam
|
|
131
136
|
end
|
132
137
|
RUBY
|
133
138
|
|
134
|
-
inject_into_class
|
139
|
+
inject_into_class "config/application.rb", "Application", config
|
135
140
|
end
|
136
141
|
|
137
142
|
def component_generator
|
@@ -139,5 +144,29 @@ module TractorBeam
|
|
139
144
|
|
140
145
|
template "component_generator", "lib/generators/component_generator.rb"
|
141
146
|
end
|
147
|
+
|
148
|
+
# Default Rails Features
|
149
|
+
|
150
|
+
def setup_rails_ujs
|
151
|
+
say "Installing rails-ujs"
|
152
|
+
|
153
|
+
run "yarn add rails-ujs"
|
154
|
+
end
|
155
|
+
|
156
|
+
def setup_actioncable
|
157
|
+
return if options[:skip_action_cable]
|
158
|
+
say "Installing actioncable"
|
159
|
+
|
160
|
+
run "yarn add actioncable"
|
161
|
+
|
162
|
+
empty_directory "frontend/client"
|
163
|
+
template "cable_js", "frontend/client/cable.js", force: true
|
164
|
+
end
|
165
|
+
|
166
|
+
def setup_turbolinks
|
167
|
+
return if options[:skip_turbolinks]
|
168
|
+
|
169
|
+
run "yarn add turbolinks"
|
170
|
+
end
|
142
171
|
end
|
143
172
|
end
|
@@ -1,45 +1,47 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
require "rails/generators/rails/app/app_generator"
|
3
5
|
|
4
6
|
module TractorBeam
|
5
7
|
class AppGenerator < Rails::Generators::AppGenerator
|
6
8
|
hide!
|
7
9
|
|
8
10
|
class_option :database, type: :string, aliases: "-d", default: "postgresql",
|
9
|
-
|
11
|
+
desc: "Configure for selected database (options: #{DATABASES.join('/')})"
|
10
12
|
|
11
13
|
class_option :version, type: :boolean, aliases: "-v", group: :tractor_beam,
|
12
|
-
|
14
|
+
desc: "Show TractorBeam version number and quit"
|
13
15
|
|
14
|
-
class_option :help, type: :boolean, aliases:
|
15
|
-
|
16
|
+
class_option :help, type: :boolean, aliases: "-h", group: :tractor_beam,
|
17
|
+
desc: "Show this help message and quit"
|
16
18
|
|
17
19
|
class_option :path, type: :string, default: nil,
|
18
|
-
|
20
|
+
desc: "Path to the gem"
|
19
21
|
|
20
22
|
class_option :skip_test, type: :boolean, default: true,
|
21
|
-
|
23
|
+
desc: "Skip Test Unit"
|
22
24
|
|
23
25
|
class_option :skip_system_test, type: :boolean, default: true,
|
24
|
-
|
26
|
+
desc: "Skip system test files"
|
25
27
|
|
26
28
|
class_option :skip_turbolinks, type: :boolean, default: true,
|
27
|
-
|
29
|
+
desc: "Skip turbolinks gem"
|
28
30
|
|
29
31
|
class_option :skip_sprockets, type: :boolean, aliases: "-S",
|
30
|
-
|
32
|
+
default: true, desc: "Skip Sprockets files"
|
31
33
|
|
32
34
|
class_option :skip_coffee, type: :boolean, default: true,
|
33
|
-
|
35
|
+
desc: "Don't use CoffeeScript"
|
34
36
|
|
35
37
|
class_option :webpack, type: :string, default: "webpack",
|
36
|
-
|
37
|
-
|
38
|
-
def finish_template
|
39
|
-
invoke :beam_customizations
|
38
|
+
desc: "Preconfigure for app-like JavaScript with Webpack (options: #{WEBPACKS.join('/')})"
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
# def finish_template
|
41
|
+
# invoke :beam_customizations
|
42
|
+
#
|
43
|
+
# super
|
44
|
+
# end
|
43
45
|
|
44
46
|
def beam_customizations
|
45
47
|
build :set_ruby_version
|
@@ -48,6 +50,7 @@ module TractorBeam
|
|
48
50
|
invoke :setup_production_environment
|
49
51
|
invoke :run_bundle
|
50
52
|
invoke :run_webpack
|
53
|
+
invoke :setup_defaul_rails_features_on_webpack
|
51
54
|
invoke :setup_component_based_frontend
|
52
55
|
invoke :setup_linters
|
53
56
|
invoke :generate_spring_binstubs
|
@@ -89,6 +92,12 @@ module TractorBeam
|
|
89
92
|
build :procfile
|
90
93
|
end
|
91
94
|
|
95
|
+
def setup_defaul_rails_features_on_webpack
|
96
|
+
build :setup_rails_ujs
|
97
|
+
build :setup_actioncable
|
98
|
+
build :setup_turbolinks
|
99
|
+
end
|
100
|
+
|
92
101
|
def git_first_commit
|
93
102
|
say "Commiting skeleton app to git"
|
94
103
|
|
@@ -106,6 +115,10 @@ OUTRO
|
|
106
115
|
say outro_text, :blue
|
107
116
|
end
|
108
117
|
|
118
|
+
def self.banner
|
119
|
+
"tractor_beam #{arguments.map(&:usage).join(' ')} [options]"
|
120
|
+
end
|
121
|
+
|
109
122
|
protected
|
110
123
|
|
111
124
|
def get_builder_class
|
data/lib/tractor_beam/version.rb
CHANGED
data/lib/tractor_beam.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.describe "Command line help output" do
|
6
|
+
let(:help_text) { tractor_beam_help_command }
|
7
|
+
|
8
|
+
it "does not contain the default rails usage statement" do
|
9
|
+
expect(help_text).not_to include("rails new APP_PATH [options]")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "provides the correct usage statement for tractor_beam" do
|
13
|
+
expect(help_text).to include <<~TEXT
|
14
|
+
Usage:
|
15
|
+
tractor_beam APP_PATH [options]
|
16
|
+
TEXT
|
17
|
+
end
|
18
|
+
|
19
|
+
it "does not contain the default rails group" do
|
20
|
+
expect(help_text).not_to include("Rails options:")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "provides help and version usage within the tractor_beam group" do
|
24
|
+
expect(help_text).to include <<~TEXT
|
25
|
+
Tractor_beam options:
|
26
|
+
-h, [--help], [--no-help] # Show this help message and quit
|
27
|
+
-v, [--version], [--no-version] # Show TractorBeam version number and quit
|
28
|
+
TEXT
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does not show the default extended rails help section" do
|
32
|
+
expect(help_text).not_to include("Create tractor_beam files for app generator.")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "contains the usage statement from the tractor_beam gem" do
|
36
|
+
expect(help_text).to include IO.read(usage_file)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.describe "Bootstraps new project with default configuration" do
|
6
|
+
before(:all) do
|
7
|
+
drop_dummy_database
|
8
|
+
remove_project_directory
|
9
|
+
run_tractor_beam
|
10
|
+
end
|
11
|
+
|
12
|
+
it "uses custom Gemfile" do
|
13
|
+
gemfile_file = IO.read("#{project_path}/Gemfile")
|
14
|
+
expect(gemfile_file).to match(
|
15
|
+
/^ruby "#{TractorBeam::RUBY_VERSION}"$/,
|
16
|
+
)
|
17
|
+
expect(gemfile_file).to match(
|
18
|
+
/^gem "rails", "#{TractorBeam::RAILS_VERSION}"$/,
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
# it "ensures project specs pass" do
|
23
|
+
# Dir.chdir(project_path) do
|
24
|
+
# Bundler.with_clean_env do
|
25
|
+
# expect(`rake`).to include('0 failures')
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
|
30
|
+
# it "includes the bundle:audit task" do
|
31
|
+
# Dir.chdir(project_path) do
|
32
|
+
# Bundler.with_clean_env do
|
33
|
+
# expect(`rails -T`).to include("rails bundle:audit")
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
|
38
|
+
it "creates .ruby-version from TractorBeam .ruby-version" do
|
39
|
+
ruby_version_file = IO.read("#{project_path}/.ruby-version")
|
40
|
+
|
41
|
+
expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
# it "copies dotfiles" do
|
45
|
+
# %w[.ctags .env].each do |dotfile|
|
46
|
+
# expect(File).to exist("#{project_path}/#{dotfile}")
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
|
50
|
+
it "doesn't generate test directory" do
|
51
|
+
expect(File).not_to exist("#{project_path}/test")
|
52
|
+
end
|
53
|
+
|
54
|
+
# it "loads secret_key_base from env" do
|
55
|
+
# secrets_file = IO.read("#{project_path}/config/secrets.yml")
|
56
|
+
#
|
57
|
+
# expect(secrets_file).
|
58
|
+
# to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
|
59
|
+
# end
|
60
|
+
|
61
|
+
it "adds bin/setup file" do
|
62
|
+
expect(File).to exist("#{project_path}/bin/setup")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "makes bin/setup executable" do
|
66
|
+
bin_setup_path = "#{project_path}/bin/setup"
|
67
|
+
|
68
|
+
expect(File.stat(bin_setup_path)).to be_executable
|
69
|
+
end
|
70
|
+
|
71
|
+
# it "adds support file for action mailer" do
|
72
|
+
# expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
|
73
|
+
# end
|
74
|
+
|
75
|
+
# it "configures capybara-webkit" do
|
76
|
+
# expect(File).to exist("#{project_path}/spec/support/capybara_webkit.rb")
|
77
|
+
# end
|
78
|
+
|
79
|
+
# it "adds support file for i18n" do
|
80
|
+
# expect(File).to exist("#{project_path}/spec/support/i18n.rb")
|
81
|
+
# end
|
82
|
+
|
83
|
+
# it "initializes ActiveJob to avoid memory bloat" do
|
84
|
+
# expect(File).
|
85
|
+
# to exist("#{project_path}/config/initializers/active_job.rb")
|
86
|
+
# end
|
87
|
+
|
88
|
+
# fit "raises on unpermitted parameters in all environments" do
|
89
|
+
# result = IO.read("#{project_path}/config/application.rb")
|
90
|
+
#
|
91
|
+
# expect(result).to match(
|
92
|
+
# /^ +config.action_controller.action_on_unpermitted_parameters = :raise$/,
|
93
|
+
# )
|
94
|
+
# end
|
95
|
+
|
96
|
+
# it "configures production environment to enforce SSL" do
|
97
|
+
# expect(production_config).to match(
|
98
|
+
# /^ +config.force_ssl = true/,
|
99
|
+
# )
|
100
|
+
# end
|
101
|
+
|
102
|
+
# it "configs simple_form" do
|
103
|
+
# expect(File).to exist("#{project_path}/config/initializers/simple_form.rb")
|
104
|
+
# end
|
105
|
+
|
106
|
+
# it "configs :test email delivery method for development" do
|
107
|
+
# expect(development_config).
|
108
|
+
# to match(/^ +config.action_mailer.delivery_method = :file$/)
|
109
|
+
# end
|
110
|
+
|
111
|
+
# it "sets action mailer default host and asset host" do
|
112
|
+
# config_key = 'config\.action_mailer\.asset_host'
|
113
|
+
# config_value =
|
114
|
+
# %q{ENV\.fetch\("ASSET_HOST", ENV\.fetch\("APPLICATION_HOST"\)\)}
|
115
|
+
# expect(production_config).to match(/#{config_key} = #{config_value}/)
|
116
|
+
# end
|
117
|
+
|
118
|
+
# it "uses APPLICATION_HOST, not HOST in the production config" do
|
119
|
+
# expect(production_config).to match(/"APPLICATION_HOST"/)
|
120
|
+
# expect(production_config).not_to match(/"HOST"/)
|
121
|
+
# end
|
122
|
+
|
123
|
+
# it "configures email interceptor in smtp config" do
|
124
|
+
# smtp_file = IO.read("#{project_path}/config/smtp.rb")
|
125
|
+
# expect(smtp_file).
|
126
|
+
# to match(/RecipientInterceptor.new\(ENV\["EMAIL_RECIPIENTS"\]\)/)
|
127
|
+
# end
|
128
|
+
|
129
|
+
it "adds spring to binstubs" do
|
130
|
+
expect(File).to exist("#{project_path}/bin/spring")
|
131
|
+
|
132
|
+
bin_stubs = %w(rake rails rspec)
|
133
|
+
bin_stubs.each do |bin_stub|
|
134
|
+
expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# it "removes comments and extra newlines from config files" do
|
139
|
+
# config_files = [
|
140
|
+
# IO.read("#{project_path}/config/application.rb"),
|
141
|
+
# IO.read("#{project_path}/config/environment.rb"),
|
142
|
+
# development_config,
|
143
|
+
# test_config,
|
144
|
+
# production_config,
|
145
|
+
# ]
|
146
|
+
#
|
147
|
+
# config_files.each do |file|
|
148
|
+
# expect(file).not_to match(/.*#.*/)
|
149
|
+
# expect(file).not_to match(/^$\n/)
|
150
|
+
# end
|
151
|
+
# end
|
152
|
+
|
153
|
+
# it "copies factories.rb" do
|
154
|
+
# expect(File).to exist("#{project_path}/spec/factories.rb")
|
155
|
+
# end
|
156
|
+
|
157
|
+
def app_name
|
158
|
+
TractorBeamTestHelpers::APP_NAME
|
159
|
+
end
|
160
|
+
|
161
|
+
# it "configure modern frontend tools" do
|
162
|
+
# flashes_path = %w(app assets stylesheets refills _flashes.scss)
|
163
|
+
# expect(read_project_file(flashes_path)).to match(/\$flashes/m)
|
164
|
+
#
|
165
|
+
# app_css = read_project_file(%w(app assets stylesheets application.scss))
|
166
|
+
# expect(app_css).to match(
|
167
|
+
# /normalize\.css\/normalize\.css.*bourbon.*neat.*base.*refills/m,
|
168
|
+
# )
|
169
|
+
# end
|
170
|
+
|
171
|
+
it "doesn't use turbolinks" do
|
172
|
+
js_file = read_project_file(%w(frontend init index.js))
|
173
|
+
expect(js_file).not_to match(/Turbolinks/)
|
174
|
+
end
|
175
|
+
|
176
|
+
it "use rails-ujs" do
|
177
|
+
js_file = read_project_file(%w(frontend init index.js))
|
178
|
+
expect(js_file).to match(/Rails/)
|
179
|
+
end
|
180
|
+
|
181
|
+
it "setup actioncable" do
|
182
|
+
js_file = read_project_file(%w(frontend client cable.js))
|
183
|
+
expect(js_file).to match(/actioncable/)
|
184
|
+
end
|
185
|
+
|
186
|
+
def development_config
|
187
|
+
@_development_config ||=
|
188
|
+
read_project_file %w(config environments development.rb)
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_config
|
192
|
+
@_test_config ||= read_project_file %w(config environments test.rb)
|
193
|
+
end
|
194
|
+
|
195
|
+
def production_config
|
196
|
+
@_production_config ||=
|
197
|
+
read_project_file %w(config environments production.rb)
|
198
|
+
end
|
199
|
+
|
200
|
+
def read_project_file(path)
|
201
|
+
IO.read(File.join(project_path, *path))
|
202
|
+
end
|
203
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "simplecov"
|
4
|
+
if ENV["CIRCLE_ARTIFACTS"]
|
5
|
+
dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
|
6
|
+
SimpleCov.coverage_dir(dir)
|
7
|
+
end
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter "/spec/"
|
10
|
+
end
|
11
|
+
|
1
12
|
require "bundler/setup"
|
2
|
-
|
13
|
+
|
14
|
+
Bundler.require(:default, :test)
|
15
|
+
Dir["./spec/support/**/*.rb"].each { |file| require file }
|
3
16
|
|
4
17
|
RSpec.configure do |config|
|
5
|
-
|
6
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
18
|
+
config.include SuspendersTestHelpers
|
7
19
|
|
8
|
-
|
9
|
-
|
20
|
+
config.before(:all) do
|
21
|
+
create_tmp_directory
|
22
|
+
end
|
10
23
|
|
11
24
|
config.expect_with :rspec do |c|
|
12
25
|
c.syntax = :expect
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SuspendersTestHelpers
|
4
|
+
APP_NAME = "dummy_app"
|
5
|
+
|
6
|
+
def remove_project_directory
|
7
|
+
FileUtils.rm_rf(project_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_tmp_directory
|
11
|
+
FileUtils.mkdir_p(tmp_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_tractor_beam(arguments = nil)
|
15
|
+
Dir.chdir(tmp_path) do
|
16
|
+
Bundler.with_clean_env do
|
17
|
+
`#{tractor_beam_bin} #{APP_NAME} #{arguments}`
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def tractor_beam_help_command
|
23
|
+
Dir.chdir(tmp_path) do
|
24
|
+
Bundler.with_clean_env do
|
25
|
+
`#{tractor_beam_bin} -h`
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_app_dependencies
|
31
|
+
return unless File.exist?(project_path)
|
32
|
+
|
33
|
+
Dir.chdir(project_path) do
|
34
|
+
Bundler.with_clean_env do
|
35
|
+
`bundle check || bundle install`
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def drop_dummy_database
|
41
|
+
return unless File.exist?(project_path)
|
42
|
+
|
43
|
+
Dir.chdir(project_path) do
|
44
|
+
Bundler.with_clean_env do
|
45
|
+
`rails db:drop`
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def project_path
|
51
|
+
@project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
|
52
|
+
end
|
53
|
+
|
54
|
+
def usage_file
|
55
|
+
@usage_path ||= File.join(root_path, "USAGE")
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def tmp_path
|
61
|
+
@tmp_path ||= Pathname.new("#{root_path}/tmp")
|
62
|
+
end
|
63
|
+
|
64
|
+
def tractor_beam_bin
|
65
|
+
File.join(root_path, "bin", "tractor_beam")
|
66
|
+
end
|
67
|
+
|
68
|
+
def root_path
|
69
|
+
File.expand_path("../../../", __FILE__)
|
70
|
+
end
|
71
|
+
end
|
data/templates/bin_setup
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "pathname"
|
3
|
+
require "fileutils"
|
4
4
|
include FileUtils
|
5
5
|
|
6
6
|
# path to your application root.
|
7
|
-
APP_ROOT = Pathname.new File.expand_path(
|
7
|
+
APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)
|
8
8
|
|
9
9
|
def system!(*args)
|
10
10
|
system(*args) || abort("\n== Command #{args} failed ==")
|
@@ -14,17 +14,17 @@ chdir APP_ROOT do
|
|
14
14
|
# This script is a starting point to setup your application.
|
15
15
|
# Add necessary setup steps to this file.
|
16
16
|
|
17
|
-
puts
|
18
|
-
system!
|
19
|
-
system(
|
17
|
+
puts "== Installing dependencies =="
|
18
|
+
system! "gem install bundler --conservative"
|
19
|
+
system("bundle check") || system!("bundle install")
|
20
20
|
|
21
21
|
puts "\n== Preparing database =="
|
22
|
-
system!
|
23
|
-
system!
|
22
|
+
system! "bin/rails db:create"
|
23
|
+
system! "bin/rails db:migrate"
|
24
24
|
|
25
25
|
puts "\n== Removing old logs and tempfiles =="
|
26
|
-
system!
|
26
|
+
system! "bin/rails log:clear tmp:clear"
|
27
27
|
|
28
28
|
puts "\n== Restarting application server =="
|
29
|
-
system!
|
29
|
+
system! "bin/rails restart"
|
30
30
|
end
|
data/templates/cable_js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
// frontend/client/cable.js
|
2
|
+
import cable from "actioncable";
|
3
|
+
|
4
|
+
let consumer;
|
5
|
+
|
6
|
+
function createChannel(...args) {
|
7
|
+
if (!consumer) {
|
8
|
+
consumer = cable.createConsumer();
|
9
|
+
}
|
10
|
+
|
11
|
+
return consumer.subscriptions.create(...args);
|
12
|
+
}
|
13
|
+
|
14
|
+
export default createChannel;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// Insert any global javascript needed on initialization here
|
2
|
+
import Rails from "rails-ujs";
|
3
|
+
<% unless options[:skip_turbolinks] %>
|
4
|
+
import Turbolinks from "turbolinks";
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
|
8
|
+
Rails.start();
|
9
|
+
<% unless options[:skip_turbolinks] %>
|
10
|
+
Turbolinks.start();
|
11
|
+
<% end %>
|
data/tractor_beam.gemspec
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
4
|
require "tractor_beam/version"
|
3
|
-
require
|
5
|
+
require "date"
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
8
|
spec.required_ruby_version = ">= #{TractorBeam::RUBY_VERSION}"
|
7
|
-
spec.required_rubygems_version = ">= 2.7.
|
9
|
+
spec.required_rubygems_version = ">= 2.7.3"
|
8
10
|
spec.authors = ["Gabriel Gizotti"]
|
9
11
|
spec.email = ["gabriel@gizotti.com"]
|
10
|
-
spec.date = Date.today.strftime(
|
12
|
+
spec.date = Date.today.strftime("%Y-%m-%d")
|
11
13
|
spec.name = "tractor_beam"
|
12
14
|
spec.version = TractorBeam::VERSION
|
13
15
|
|
14
|
-
spec.description
|
16
|
+
spec.description = <<-HERE
|
15
17
|
Tractor Beam is a base Rails project with all the modern javascript goodness
|
16
18
|
described by https://evilmartians.com/chronicles/evil-front-part-1.
|
17
19
|
Use it to get your rails app up and running with webpacker and a component
|
@@ -27,7 +29,10 @@ HERE
|
|
27
29
|
spec.executables = ["tractor_beam"]
|
28
30
|
spec.require_paths = ["lib"]
|
29
31
|
|
30
|
-
spec.add_dependency
|
32
|
+
spec.add_dependency "rails", TractorBeam::RAILS_VERSION
|
31
33
|
|
32
34
|
spec.add_development_dependency "rspec", "~> 3.2"
|
35
|
+
spec.add_development_dependency "rubocop", "0.52.1"
|
36
|
+
spec.add_development_dependency "rubocop-rspec", "1.22.0"
|
37
|
+
spec.add_development_dependency "simplecov", "~> 0.12.0"
|
33
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tractor_beam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Gizotti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.52.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.52.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.22.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.22.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.12.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.12.0
|
41
83
|
description: |
|
42
84
|
Tractor Beam is a base Rails project with all the modern javascript goodness
|
43
85
|
described by https://evilmartians.com/chronicles/evil-front-part-1.
|
@@ -52,12 +94,15 @@ extra_rdoc_files: []
|
|
52
94
|
files:
|
53
95
|
- ".gitignore"
|
54
96
|
- ".rspec"
|
97
|
+
- ".rubocop.yml"
|
55
98
|
- ".ruby-version"
|
56
99
|
- ".travis.yml"
|
100
|
+
- CHANGELOG.md
|
57
101
|
- Gemfile
|
58
102
|
- LICENSE.txt
|
59
103
|
- README.md
|
60
104
|
- Rakefile
|
105
|
+
- USAGE
|
61
106
|
- bin/console
|
62
107
|
- bin/setup
|
63
108
|
- bin/tractor_beam
|
@@ -65,18 +110,21 @@ files:
|
|
65
110
|
- lib/tractor_beam/app_builder.rb
|
66
111
|
- lib/tractor_beam/generators/app_generator.rb
|
67
112
|
- lib/tractor_beam/version.rb
|
113
|
+
- spec/features/cli_help_spec.rb
|
114
|
+
- spec/features/new_project_spec.rb
|
68
115
|
- spec/spec_helper.rb
|
69
|
-
- spec/
|
116
|
+
- spec/support/tractor_beam.rb
|
70
117
|
- templates/Gemfile.erb
|
71
118
|
- templates/Procfile
|
72
119
|
- templates/Procfile.dev
|
73
120
|
- templates/Readme.md.erb
|
74
121
|
- templates/bin_setup
|
75
122
|
- templates/browserlistrc
|
123
|
+
- templates/cable_js
|
76
124
|
- templates/component_generator
|
77
125
|
- templates/eslintrc
|
78
126
|
- templates/frontend/init/index.css
|
79
|
-
- templates/frontend/init/index.js
|
127
|
+
- templates/frontend/init/index.js.erb
|
80
128
|
- templates/frontend/packs/application.js
|
81
129
|
- templates/stylelintrc
|
82
130
|
- templates/tractor_beam_gitignore
|
@@ -99,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
147
|
requirements:
|
100
148
|
- - ">="
|
101
149
|
- !ruby/object:Gem::Version
|
102
|
-
version: 2.7.
|
150
|
+
version: 2.7.3
|
103
151
|
requirements: []
|
104
152
|
rubyforge_project:
|
105
153
|
rubygems_version: 2.7.4
|
@@ -107,5 +155,7 @@ signing_key:
|
|
107
155
|
specification_version: 4
|
108
156
|
summary: Generate a Rails app using modern javascript tooling.
|
109
157
|
test_files:
|
158
|
+
- spec/features/cli_help_spec.rb
|
159
|
+
- spec/features/new_project_spec.rb
|
110
160
|
- spec/spec_helper.rb
|
111
|
-
- spec/
|
161
|
+
- spec/support/tractor_beam.rb
|
data/spec/tractor_beam_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
// Insert any global javascript needed on initialization here
|