code42template 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -9
- data/NEWS.md +9 -0
- data/README.md +15 -0
- data/lib/code42template/adapters/heroku.rb +12 -17
- data/lib/code42template/app_builder.rb +1 -0
- data/lib/code42template/generators/app_generator.rb +3 -0
- data/lib/code42template/version.rb +1 -1
- data/spec/features/new_project_spec.rb +6 -9
- data/templates/application.js +1 -1
- data/templates/dotfiles/.eslintignore +6 -0
- data/templates/dotfiles/.eslintrc +16 -0
- data/templates/health.rake +4 -2
- data/templates/package.json +7 -1
- data/templates/puma.rb +1 -1
- data/templates/rails_helper.rb +21 -15
- data/templates/test_env_eslintrc +6 -0
- data/templates/webpack.config.js +6 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00d1971ef9751231515417d56a4d31b697fb4b8a
|
4
|
+
data.tar.gz: 57ad678ed7bbae98a4b387bc7f4335a18ad7b069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95a90e46ed2da02596cef3366348216a1645bc1da6bd2ea7af69f0ec4c1a717772bec972c5e852ab52c973366669452c486365c3dd22c52e5120ee21d1ab06ff
|
7
|
+
data.tar.gz: d26fe21edbcc2bfd180d67839d83af39b32318e413d9090132f07529d4a18097c60827ed3a430fc0e19338a7e4d9566b27c4c22fc7c5672f2b7fb0a34e8f85a2
|
data/.travis.yml
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
language: ruby
|
2
|
-
rvm:
|
3
|
-
|
4
|
-
sudo: false
|
2
|
+
rvm:
|
3
|
+
- 2.3.1
|
5
4
|
before_install:
|
6
|
-
-
|
7
|
-
|
8
|
-
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
- nvm install 6.2.0
|
6
|
+
install:
|
7
|
+
- bundle install --jobs=3 --retry=3
|
8
|
+
- npm install
|
9
|
+
script:
|
10
|
+
- bundle exec rspec
|
data/NEWS.md
CHANGED
@@ -54,3 +54,12 @@
|
|
54
54
|
* Improve bin/setup script
|
55
55
|
* Do not remove comments from generated files anymore
|
56
56
|
* Improve README
|
57
|
+
|
58
|
+
2.1.0 (October 10 2016)
|
59
|
+
|
60
|
+
* Fix bin/setup script regarding Heroku - it does not try to join as a collaborator anymore
|
61
|
+
* Fix health rake task regarding rspec
|
62
|
+
* Add eslint / eslint configuration
|
63
|
+
* Add sinon - needs "import sinon from 'sinon';" manual require in tests
|
64
|
+
* Make it possible to generate an app without ActiveRecord
|
65
|
+
* Configure Travis CI
|
data/README.md
CHANGED
@@ -154,6 +154,7 @@ tasks:
|
|
154
154
|
- `bundle-audit` and `brakeman` check if your app does not have basic
|
155
155
|
security holes.
|
156
156
|
- `rubocop` makes sure your code adheres to style guidelines.
|
157
|
+
- `eslint` makes sure your JavaScript code conforms to fine standards
|
157
158
|
|
158
159
|
### Continuous integration
|
159
160
|
|
@@ -237,6 +238,20 @@ output a URL where you can run all tests:
|
|
237
238
|
|
238
239
|
npm test:browser
|
239
240
|
|
241
|
+
#### JavaScript: eslint
|
242
|
+
|
243
|
+
To run eslint over all JS files issue the following command:
|
244
|
+
|
245
|
+
npm run lint
|
246
|
+
|
247
|
+
#### JavaScript: sinon
|
248
|
+
|
249
|
+
The template comes with `sinon` already pre-configured. Sinon is a popular
|
250
|
+
mocking and stubbing tool for JavaScript. To import it in a test file use the
|
251
|
+
following ES6 import instruction:
|
252
|
+
|
253
|
+
import sinon from 'sinon';
|
254
|
+
|
240
255
|
### Application server
|
241
256
|
|
242
257
|
We use [puma](https://github.com/puma/puma) as our application server, which
|
@@ -46,11 +46,19 @@ module Code42Template
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def set_heroku_remotes
|
49
|
-
|
50
|
-
|
51
|
-
#{command_to_join_heroku_app('production')}
|
49
|
+
staging_app_name = heroku_app_name_for('staging')
|
50
|
+
production_app_name = heroku_app_name_for('production')
|
52
51
|
|
53
|
-
|
52
|
+
remotes = <<~SHELL
|
53
|
+
`git remote add staging git@heroku.com:#{staging_app_name}.git 2> /dev/null`
|
54
|
+
`git remote add production git@heroku.com:#{production_app_name}.git 2> /dev/null`
|
55
|
+
`git config heroku.remote staging`
|
56
|
+
|
57
|
+
puts
|
58
|
+
puts 'If you already have access, try joining this app as a collaborator with the following commands:'
|
59
|
+
puts
|
60
|
+
puts "heroku join --app #{staging_app_name}"
|
61
|
+
puts "heroku join --app #{production_app_name}"
|
54
62
|
SHELL
|
55
63
|
|
56
64
|
@app_builder.append_file 'bin/setup', remotes
|
@@ -141,19 +149,6 @@ module Code42Template
|
|
141
149
|
|
142
150
|
private
|
143
151
|
|
144
|
-
def command_to_join_heroku_app(environment)
|
145
|
-
heroku_app_name = heroku_app_name_for(environment)
|
146
|
-
|
147
|
-
<<~SHELL
|
148
|
-
if heroku join --app #{heroku_app_name} &> /dev/null; then
|
149
|
-
git remote add #{environment} git@heroku.com:#{heroku_app_name}.git || true
|
150
|
-
printf 'You are a collaborator on the "#{heroku_app_name}" Heroku app\n'
|
151
|
-
else
|
152
|
-
printf 'Ask for access to the "#{heroku_app_name}" Heroku app\n'
|
153
|
-
fi
|
154
|
-
SHELL
|
155
|
-
end
|
156
|
-
|
157
152
|
def heroku_app_name
|
158
153
|
@app_builder.app_name.dasherize
|
159
154
|
end
|
@@ -59,6 +59,8 @@ module Code42Template
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def setup_database
|
62
|
+
return if options['skip_active_record']
|
63
|
+
|
62
64
|
say 'Setting up database'
|
63
65
|
|
64
66
|
if 'postgresql' == options[:database]
|
@@ -156,6 +158,7 @@ module Code42Template
|
|
156
158
|
|
157
159
|
def setup_dotfiles
|
158
160
|
build :copy_dotfiles
|
161
|
+
build :copy_eslint_config
|
159
162
|
end
|
160
163
|
|
161
164
|
def setup_default_directories
|
@@ -20,21 +20,16 @@ RSpec.describe "Create a new project with default configuration" do
|
|
20
20
|
|
21
21
|
it "ensures project specs pass" do
|
22
22
|
copy_file 'smoke_test.rb', 'spec/models/smoke_test_spec.rb'
|
23
|
-
copy_file 'feature_smoke_test.rb', 'spec/models/feature_smoke_spec.rb'
|
24
23
|
copy_file 'routes.rb', 'config/routes.rb'
|
25
|
-
copy_file 'home_controller.rb', 'app/controllers/home_controller.rb'
|
26
|
-
copy_file 'index.html.erb', 'app/views/home/index.html.erb'
|
27
24
|
|
28
25
|
Dir.chdir(project_path) do
|
29
26
|
Bundler.with_clean_env do
|
30
|
-
expect(`rake health`).to include(
|
31
|
-
'
|
27
|
+
expect(`NO_NPM_TEST=true rake health`).to include(
|
28
|
+
'1 example, 0 failures', # rspec
|
32
29
|
'LOC (100.0%) covered.', # simplecov
|
33
30
|
'no offenses detected', # rubocop
|
34
31
|
'Security Warnings | 0', # brakeman
|
35
|
-
'No vulnerabilities found'
|
36
|
-
'1 passing', # mocha
|
37
|
-
'TOTAL: 1 SUCCESS' # karma
|
32
|
+
'No vulnerabilities found' # bundler-audit
|
38
33
|
)
|
39
34
|
end
|
40
35
|
end
|
@@ -47,9 +42,11 @@ RSpec.describe "Create a new project with default configuration" do
|
|
47
42
|
end
|
48
43
|
|
49
44
|
it "copies dotfiles" do
|
50
|
-
%w[.env .rspec .codeclimate.yml].each do |dotfile|
|
45
|
+
%w[.env .rspec .codeclimate.yml .eslintrc .eslintignore].each do |dotfile|
|
51
46
|
expect(File).to exist("#{project_path}/#{dotfile}")
|
52
47
|
end
|
48
|
+
|
49
|
+
expect(File).to exist("#{project_path}/spec/javascripts/.eslintrc")
|
53
50
|
end
|
54
51
|
|
55
52
|
it 'copies rspec configuration' do
|
data/templates/application.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
// This is where you should bootstrap your JS app
|
data/templates/health.rake
CHANGED
@@ -11,9 +11,11 @@ if Rails.env.development? || Rails.env.test?
|
|
11
11
|
desc 'Checks app health: runs tests, security checks and rubocop'
|
12
12
|
task :health do
|
13
13
|
rails_helper = Rails.root / 'spec/rails_helper.rb'
|
14
|
+
rspec_env = { 'COVERAGE' => 'true', 'RAILS_ENV' => 'test' }
|
14
15
|
|
15
|
-
run_command "bundle exec rspec -r#{rails_helper}",
|
16
|
-
run_command 'npm run test'
|
16
|
+
run_command "bundle exec rspec -r#{rails_helper}", rspec_env
|
17
|
+
run_command 'npm run test' unless ENV['NO_NPM_TEST']
|
18
|
+
run_command 'npm run lint'
|
17
19
|
run_command 'bundle exec bundle-audit update'
|
18
20
|
run_command 'bundle exec bundle-audit check'
|
19
21
|
run_command 'bundle exec brakeman -z'
|
data/templates/package.json
CHANGED
@@ -15,6 +15,10 @@
|
|
15
15
|
},
|
16
16
|
"devDependencies": {
|
17
17
|
"chai": "^3.5.0",
|
18
|
+
"eslint": "^3.5.0",
|
19
|
+
"eslint-config-airbnb-base": "^7.1.0",
|
20
|
+
"eslint-import-resolver-webpack": "^0.6.0",
|
21
|
+
"eslint-plugin-import": "^1.15.0",
|
18
22
|
"karma": "^0.13.22",
|
19
23
|
"karma-chai": "^0.1.0",
|
20
24
|
"karma-chrome-launcher": "^1.0.1",
|
@@ -26,9 +30,11 @@
|
|
26
30
|
"karma-webpack": "^1.7.0",
|
27
31
|
"mocha": "^2.4.5",
|
28
32
|
"mocha-loader": "^0.7.1",
|
29
|
-
"mocha-webpack": "^0.4.0"
|
33
|
+
"mocha-webpack": "^0.4.0",
|
34
|
+
"sinon": "^1.17.5"
|
30
35
|
},
|
31
36
|
"scripts": {
|
37
|
+
"lint": "eslint .",
|
32
38
|
"test": "npm run test:unit && npm run test:integration",
|
33
39
|
"test:unit": "NODE_ENV=test NODE_PATH='./app/assets/javascripts' mocha-webpack",
|
34
40
|
"test:unit:watch": "npm run test:unit -- --watch",
|
data/templates/puma.rb
CHANGED
@@ -24,5 +24,5 @@ environment ENV.fetch("RACK_ENV", "development")
|
|
24
24
|
on_worker_boot do
|
25
25
|
# Worker specific setup for Rails 4.1+
|
26
26
|
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
|
27
|
-
ActiveRecord::Base.establish_connection
|
27
|
+
ActiveRecord::Base.establish_connection if defined? ActiveRecord
|
28
28
|
end
|
data/templates/rails_helper.rb
CHANGED
@@ -21,7 +21,11 @@ end
|
|
21
21
|
|
22
22
|
if ENV['COVERAGE']
|
23
23
|
%w(Controller Record Mailer Job).each do |klass|
|
24
|
-
|
24
|
+
begin
|
25
|
+
Object.const_get "Application#{klass}"
|
26
|
+
# rubocop:disable Lint/HandleExceptions
|
27
|
+
rescue NameError
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
@@ -29,7 +33,7 @@ require 'spec_helper'
|
|
29
33
|
require 'rspec/rails'
|
30
34
|
require 'capybara/poltergeist'
|
31
35
|
|
32
|
-
ActiveRecord::Migration.maintain_test_schema!
|
36
|
+
ActiveRecord::Migration.maintain_test_schema! if defined? ActiveRecord
|
33
37
|
|
34
38
|
Capybara.javascript_driver = :poltergeist
|
35
39
|
Capybara.default_driver = :rack_test
|
@@ -39,21 +43,23 @@ RSpec.configure do |config|
|
|
39
43
|
config.infer_spec_type_from_file_location!
|
40
44
|
config.filter_rails_from_backtrace!
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
46
|
+
if defined? ActiveRecord
|
47
|
+
config.before :suite do
|
48
|
+
DatabaseCleaner.clean_with :truncation
|
49
|
+
end
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
config.before :each do
|
52
|
+
DatabaseCleaner.strategy = :transaction
|
53
|
+
end
|
49
54
|
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
config.before :each, type: :feature do
|
56
|
+
DatabaseCleaner.strategy = :truncation
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
config.around :each do |example|
|
60
|
+
DatabaseCleaner.start
|
61
|
+
example.run
|
62
|
+
DatabaseCleaner.clean
|
63
|
+
end
|
58
64
|
end
|
59
65
|
end
|
data/templates/webpack.config.js
CHANGED
@@ -24,11 +24,15 @@ var config = {
|
|
24
24
|
module: {
|
25
25
|
loaders: [
|
26
26
|
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
|
27
|
-
{ test: /\.json$/, loader: 'json-loader' }
|
27
|
+
{ test: /\.json$/, loader: 'json-loader' },
|
28
|
+
{ test: /sinon\.js$/, loader: "imports?define=>false,require=>false"}
|
28
29
|
]
|
29
30
|
},
|
30
31
|
resolve: {
|
31
|
-
root: path.join(__dirname, '..', 'app', 'assets', 'javascripts')
|
32
|
+
root: path.join(__dirname, '..', 'app', 'assets', 'javascripts'),
|
33
|
+
alias: {
|
34
|
+
sinon: 'sinon/pkg/sinon'
|
35
|
+
}
|
32
36
|
},
|
33
37
|
plugins: [
|
34
38
|
// must match config.webpack.manifest_filename
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code42template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- codeminer42
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,6 +107,8 @@ files:
|
|
107
107
|
- templates/dotfiles/.babelrc
|
108
108
|
- templates/dotfiles/.codeclimate.yml
|
109
109
|
- templates/dotfiles/.env
|
110
|
+
- templates/dotfiles/.eslintignore
|
111
|
+
- templates/dotfiles/.eslintrc
|
110
112
|
- templates/dotfiles/.rspec
|
111
113
|
- templates/dotfiles/.rubocop.yml
|
112
114
|
- templates/feature_helper.rb.erb
|
@@ -126,6 +128,7 @@ files:
|
|
126
128
|
- templates/spec/javascripts/integration/smoke.spec.js
|
127
129
|
- templates/spec/javascripts/unit/smoke.spec.js
|
128
130
|
- templates/spec_helper.rb
|
131
|
+
- templates/test_env_eslintrc
|
129
132
|
- templates/travis.yml.erb
|
130
133
|
- templates/webpack.config.js
|
131
134
|
- templates/webpack.config.test.browser.js
|