code42template 2.0.0 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25f9b6b6283c1adf734c7de322de2cad8a852a2b
4
- data.tar.gz: 542e7cfd66f20c16858cab5a6fb45a1360326d7c
3
+ metadata.gz: 00d1971ef9751231515417d56a4d31b697fb4b8a
4
+ data.tar.gz: 57ad678ed7bbae98a4b387bc7f4335a18ad7b069
5
5
  SHA512:
6
- metadata.gz: 4d469c1365c42a9e90dad4acd623984f85f1ee14d406c9f8ad596b713b0011cb33847a82ba34039571824a6520b83f1c60d6a635735be9725e6fcec7ed6b1010
7
- data.tar.gz: 98b2e35b070cdadbbf7f7976df6b2e8a8b3dfa5723cc2eca0b1aae609419af9d39ce1efddc31bc68a4596de2f9caaa00c7e0d4303ff3150f89d82f857e9536bd
6
+ metadata.gz: 95a90e46ed2da02596cef3366348216a1645bc1da6bd2ea7af69f0ec4c1a717772bec972c5e852ab52c973366669452c486365c3dd22c52e5120ee21d1ab06ff
7
+ data.tar.gz: d26fe21edbcc2bfd180d67839d83af39b32318e413d9090132f07529d4a18097c60827ed3a430fc0e19338a7e4d9566b27c4c22fc7c5672f2b7fb0a34e8f85a2
@@ -1,11 +1,10 @@
1
1
  language: ruby
2
- rvm: 2.3.0
3
- cache: bundler
4
- sudo: false
2
+ rvm:
3
+ - 2.3.1
5
4
  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
- install: bundle install
10
- notifications:
11
- email: false
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
- remotes = <<~SHELL
50
- #{command_to_join_heroku_app('staging')}
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
- git config heroku.remote staging
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
@@ -96,6 +96,7 @@ module Code42Template
96
96
 
97
97
  def copy_dotfiles
98
98
  directory("dotfiles", ".")
99
+ copy_file 'test_env_eslintrc', 'spec/javascripts/.eslintrc'
99
100
  end
100
101
 
101
102
  def setup_continuous_integration
@@ -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
@@ -5,5 +5,5 @@ module Code42Template
5
5
  RUBY_VERSION = Pathname(__dir__).join('..', '..', '.ruby-version').read.strip
6
6
  NODE_VERSION = "6.2.0"
7
7
 
8
- VERSION = "2.0.0"
8
+ VERSION = "2.1.0"
9
9
  end
@@ -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
- '3 examples, 0 failures', # rspec
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', # bundler-audit
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
@@ -1 +1 @@
1
- (() => console.log('I am alive!'))()
1
+ // This is where you should bootstrap your JS app
@@ -0,0 +1,6 @@
1
+ public
2
+ node_modules
3
+ coverage
4
+ webpack.config.*
5
+ karma.conf.js
6
+ app/assets/javascripts/cable.js
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "airbnb-base",
3
+ "env": {
4
+ "mocha": true
5
+ },
6
+ "settings": {
7
+ "import/resolver": {
8
+ "webpack": {
9
+ "config": "config/webpack.config.js"
10
+ }
11
+ }
12
+ },
13
+ "globals": {
14
+ "window": true
15
+ }
16
+ }
@@ -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}", 'COVERAGE' => 'true'
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'
@@ -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",
@@ -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
@@ -21,7 +21,11 @@ end
21
21
 
22
22
  if ENV['COVERAGE']
23
23
  %w(Controller Record Mailer Job).each do |klass|
24
- Object.const_get "Application#{klass}"
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
- config.before :suite do
43
- DatabaseCleaner.clean_with :truncation
44
- end
46
+ if defined? ActiveRecord
47
+ config.before :suite do
48
+ DatabaseCleaner.clean_with :truncation
49
+ end
45
50
 
46
- config.before :each do
47
- DatabaseCleaner.strategy = :transaction
48
- end
51
+ config.before :each do
52
+ DatabaseCleaner.strategy = :transaction
53
+ end
49
54
 
50
- config.before :each, type: :feature do
51
- DatabaseCleaner.strategy = :truncation
52
- end
55
+ config.before :each, type: :feature do
56
+ DatabaseCleaner.strategy = :truncation
57
+ end
53
58
 
54
- config.around :each do |example|
55
- DatabaseCleaner.start
56
- example.run
57
- DatabaseCleaner.clean
59
+ config.around :each do |example|
60
+ DatabaseCleaner.start
61
+ example.run
62
+ DatabaseCleaner.clean
63
+ end
58
64
  end
59
65
  end
@@ -0,0 +1,6 @@
1
+ {
2
+ "rules": {
3
+ "no-unused-expressions": 0,
4
+ "import/no-extraneous-dependencies": [2, { "devDependencies": true }]
5
+ }
6
+ }
@@ -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.0.0
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-07-27 00:00:00.000000000 Z
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