htcht 0.1.0 → 0.1.1

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: d1cd0938dd3865ec3f78ada3ab31fefc2cf787e3
4
- data.tar.gz: 9b31904115879870d955d83f26dd68e1275c137e
3
+ metadata.gz: ec30c53f8e25b42c1b119536c829c434562aeb18
4
+ data.tar.gz: affeeb15ceb6c3cacbc4034150ba9e0d846269b2
5
5
  SHA512:
6
- metadata.gz: 5b90731d79df2cc8d8909a36de66743fc95716b9e0a71ae95015f17994b5afb5646442e2d08d235243fb0baff9cffe149880dac2d7de7729aa24955c3200dd69
7
- data.tar.gz: 616b60ba20f6c299e04c328a91e7e32b7fc81c1e0bb3cf657c514f0db5f63b3be93982784ab7692d2b6cc3a4ca7fae912430145aa5999cf066e9d23805ccb011
6
+ metadata.gz: 578361f294a77e21773df29fb22b5b8ea250a615aea08eb609645cc82b095301685b6272b6f8864e375ba656a7851dcc10985ad042167c422c12be0baacf775b
7
+ data.tar.gz: 257d9920e4dfba6547988d88c05c46b5ceb955b36119f9b3fbcbd091000ff8edffbaf2ae2db9b6e9c8711433fcd6ad40416454538969035c10ca31b807b56724
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- htcht (0.1.0)
5
- thor
4
+ htcht (0.1.1)
5
+ thor (~> 0.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -4,6 +4,8 @@ The internal CLI of Trim Agency. Used to setup new projects, build, test, etc.
4
4
 
5
5
  ## Installation
6
6
 
7
+ Htcht requires Docker and has only been tested on MacOS.
8
+
7
9
  Run this command to install
8
10
 
9
11
  $ gem install htcht
@@ -20,7 +22,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
20
22
 
21
23
  ## Contributing
22
24
 
23
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/htcht. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/TrimAgency/htcht. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
24
26
 
25
27
 
26
28
  ## License
@@ -11,34 +11,36 @@ module Htcht
11
11
 
12
12
  desc 'new AppName', 'Create a new base Rails App inside a Docker Container with Postgres setup as the database.'
13
13
  method_option :verbose, type: :boolean, default: false, :aliases => '-v', :desc => 'default: [--no-verbose] By default rails new will be run with the quiet flag, this turns it off.'
14
- method_option :api, type: :boolean, default: false, :desc => 'default: [--no-api] Generate Rails App in API mode.'
15
- method_option :bootstrap, type: :boolean, default: false, :desc => 'default: [--no-bootstrap] Generate a base Rails app with custom Gemfile and configs. (This along with "--api" is the base for new Rails APIs at Trim Agency).'
14
+ method_option :api, type: :boolean, default: false, :aliases => '-a', :desc => 'default: [--no-api] Generate Rails App in API mode.'
15
+ method_option :init, type: :boolean, default: false, :aliases => '-i', :desc => 'default: [--no-init] Generate a base Rails app with custom Gemfile and configs. (This along with "--api" is the base for new Rails APIs at Trim Agency).'
16
16
  method_option :test, type: :boolean, default: false, :desc => 'default: [--no-test]'
17
17
  def new(appname)
18
18
 
19
19
  # Format the appname as snake case for folders, etc.
20
20
  # This code is taken straight from Rails
21
+ # TODO: Move to a helper file
21
22
  snake_name = appname.gsub(/::/, '/').
22
23
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
23
24
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
24
25
  tr("-", "_").
25
26
  downcase
26
27
 
27
- rails_new_command = 'docker-compose run app rails new . --database=postgresql -T --skip-bundle'
28
+ rails_new_command = 'docker-compose run app rails new . --database=postgresql --skip-bundle'
28
29
 
29
30
  # Set the application template
30
31
  # TODO: Refactor to be dynamic from a directory
31
- if options[:bootstrap] && options[:api]
32
- copy_file('templates/api_bootstrap_template.rb', "#{snake_name}/api_bootstrap_template.rb")
32
+ if options[:init] && options[:api]
33
+ copy_file('templates/api_init_template.rb', "#{snake_name}/api_init_template.rb")
33
34
  copy_file('templates/api_build_files/user_spec.rb', "#{snake_name}/build_files/user_spec.rb")
34
35
  copy_file('templates/api_build_files/users.rb', "#{snake_name}/build_files/users.rb")
35
36
  copy_file('templates/api_build_files/email_validator.rb', "#{snake_name}/build_files/email_validator.rb")
36
37
  copy_file('templates/api_build_files/factory_girl.rb', "#{snake_name}/build_files/factory_girl.rb")
37
38
  copy_file('templates/api_build_files/shoulda_matchers.rb', "#{snake_name}/build_files/shoulda_matchers.rb")
38
39
  copy_file('templates/api_build_files/rails_helper.rb', "#{snake_name}/build_files/rails_helper.rb")
39
- rails_new_command.concat(' -m api_bootstrap_template.rb')
40
- elsif options[:bootstrap]
41
- puts "--bootstrap must be used with --api for now. This is on it's way"
40
+ copy_file('templates/api_build_files/seeds.rb', "#{snake_name}/build_files/seeds.rb")
41
+ rails_new_command.concat(' -m api_init_template.rb -T')
42
+ elsif options[:init]
43
+ puts "--init must be used with --api for now."
42
44
  return
43
45
  else
44
46
  copy_file 'templates/default_template.rb', "#{snake_name}/default_template.rb"
@@ -86,7 +88,15 @@ module Htcht
86
88
  run('docker-compose run app rake db:create')
87
89
  run('docker-compose run app rake db:migrate')
88
90
 
91
+ # Clean up the template and build files
92
+ if options[:init] && options[:api]
93
+ remove_file("api_init_template.rb")
94
+ remove_dir("build_files/")
95
+ else
96
+ remove_file("default_template.rb")
97
+ end
89
98
  end
99
+
90
100
  end
91
101
  end
92
102
  end
@@ -0,0 +1,19 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Enviroment Specific Seed data is handled with the seedbank gem and follows this structure
5
+ #
6
+ # db/seeds/
7
+ # bar.seeds.rb
8
+ # development/
9
+ # users.seeds.rb
10
+ # foo.seeds.rb
11
+ #
12
+ # This would generate the following Rake tasks
13
+ #
14
+ # rake db:seed Load the seed data from db/seeds.rb, db/seeds/*.seeds.rb and db/seeds/ENVIRONMENT/*.seeds.rb. ENVIRONMENT is the current environment in Rails.env.
15
+ # rake db:seed:bar Load the seed data from db/seeds/bar.seeds.rb
16
+ # rake db:seed:common Load the seed data from db/seeds.rb and db/seeds/*.seeds.rb.
17
+ # rake db:seed:development Load the seed data from db/seeds.rb, db/seeds/*.seeds.rb and db/seeds/development/*.seeds.rb.
18
+ # rake db:seed:development:users Load the seed data from db/seeds/development/users.seeds.rb
19
+ # rake db:seed:original Load the seed data from db/seeds.rb
@@ -73,13 +73,21 @@ run('bundle install')
73
73
 
74
74
  # Setup Rspec for Testing
75
75
  # ----------------------------
76
-
77
76
  run('rails generate rspec:install')
78
77
 
78
+ # Setup Figaro for ENV
79
+ # ----------------------------
80
+ run('bundle exec figaro install')
81
+
82
+ # Setup Knock for JWT
83
+ # ----------------------------
84
+ run('rails generate knock:install')
85
+ run('rails generate knock:token_controller user')
86
+ insert_into_file("app/controllers/application_controller.rb", "\s\sinclude Knock::Authenticable\n", :after => "class ApplicationController < ActionController::API\n")
87
+
79
88
  # Generate User Model
80
89
  # and add validations to user.rb
81
90
  # ----------------------------
82
-
83
91
  generate(:model, 'User', 'email:uniq:index', 'password:digest')
84
92
  user_migration = Dir.glob('db/migrate/*.rb')[0].to_s
85
93
  gsub_file(user_migration, 't.string :email', 't.string :email, null: false')
@@ -106,6 +114,8 @@ insert_into_file('app/models/user.rb', after: 'has_secure_password') do
106
114
  )
107
115
  end
108
116
 
117
+ # Copy remaining files to their respective locations
118
+ # ----------------------------
109
119
  remove_file('spec/models/user_spec.rb')
110
120
  copy_file('build_files/user_spec.rb', 'spec/models/user_spec.rb')
111
121
  copy_file('build_files/users.rb', 'spec/factories/users.rb')
@@ -113,5 +123,7 @@ copy_file('build_files/email_validator.rb', 'app/validators/email_validator.rb')
113
123
  copy_file('build_files/factory_girl.rb', 'spec/support/factory_girl.rb')
114
124
  copy_file('build_files/rails_helper.rb', 'spec/rails_helper.rb')
115
125
  copy_file('build_files/shoulda_matchers.rb', 'spec/support/shoulda_matchers.rb')
116
- remove_dir('build_files/')
117
-
126
+ copy_file('build_files/seeds.rb', 'db/seeds.rb')
127
+ empty_directory('db/seeds')
128
+ empty_directory('db/seeds/development')
129
+ empty_directory('db/seeds/test')
data/lib/htcht/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Htcht
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htcht
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trim Agency
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-18 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -90,13 +90,14 @@ files:
90
90
  - lib/htcht/cli/rails/Dockerfile
91
91
  - lib/htcht/cli/rails/docker-compose.yml
92
92
  - lib/htcht/cli/rails/rails.rb
93
- - lib/htcht/cli/rails/templates/api_bootstrap_template.rb
94
93
  - lib/htcht/cli/rails/templates/api_build_files/email_validator.rb
95
94
  - lib/htcht/cli/rails/templates/api_build_files/factory_girl.rb
96
95
  - lib/htcht/cli/rails/templates/api_build_files/rails_helper.rb
96
+ - lib/htcht/cli/rails/templates/api_build_files/seeds.rb
97
97
  - lib/htcht/cli/rails/templates/api_build_files/shoulda_matchers.rb
98
98
  - lib/htcht/cli/rails/templates/api_build_files/user_spec.rb
99
99
  - lib/htcht/cli/rails/templates/api_build_files/users.rb
100
+ - lib/htcht/cli/rails/templates/api_init_template.rb
100
101
  - lib/htcht/cli/rails/templates/default_template.rb
101
102
  - lib/htcht/main.rb
102
103
  - lib/htcht/version.rb