htcht 0.1.1 → 0.1.3
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/Gemfile.lock +35 -0
- data/README.md +3 -2
- data/htcht.gemspec +2 -0
- data/lib/htcht/cli/rails/BaseGemfile +2 -2
- data/lib/htcht/cli/rails/Dockerfile +2 -2
- data/lib/htcht/cli/rails/rails.rb +40 -11
- data/lib/htcht/cli/rails/templates/api_build_files/active_model_serializers.rb +1 -0
- data/lib/htcht/cli/rails/templates/api_init_template.rb +3 -12
- data/lib/htcht/cli/rails/templates/default_template.rb +2 -13
- data/lib/htcht/helpers/general_helpers.rb +12 -0
- data/lib/htcht/helpers/name_helpers.rb +15 -0
- data/lib/htcht/helpers/version_helpers.rb +20 -0
- data/lib/htcht/version.rb +1 -1
- metadata +34 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1dcda9ce862bcb132b0c0c81b738aaf15ede5c8
|
4
|
+
data.tar.gz: 7008301db5e70a32d46a11daadff04c9b900e107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8af195447abd1f753197b458c0c27aeca97c2f1db6b24810093d0ded3e70d78340c5fa81dd3642e3707034d43454bff854a357b1d84630676f22110fa9af5708
|
7
|
+
data.tar.gz: a7873e3ecf1c6678d0838b69d99e7027c543e241d6d309ec5e5f2c579b4f8409821b77b5f3d3319d3cffe14b9ff965e10fa540d0ccaa819952810140934317fd
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,39 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
aruba (0.14.2)
|
11
|
+
childprocess (~> 0.5.6)
|
12
|
+
contracts (~> 0.9)
|
13
|
+
cucumber (>= 1.3.19)
|
14
|
+
ffi (~> 1.9.10)
|
15
|
+
rspec-expectations (>= 2.99)
|
16
|
+
thor (~> 0.19)
|
17
|
+
builder (3.2.3)
|
18
|
+
childprocess (0.5.9)
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
20
|
+
coderay (1.1.1)
|
21
|
+
contracts (0.15.0)
|
22
|
+
cucumber (2.4.0)
|
23
|
+
builder (>= 2.1.2)
|
24
|
+
cucumber-core (~> 1.5.0)
|
25
|
+
cucumber-wire (~> 0.0.1)
|
26
|
+
diff-lcs (>= 1.1.3)
|
27
|
+
gherkin (~> 4.0)
|
28
|
+
multi_json (>= 1.7.5, < 2.0)
|
29
|
+
multi_test (>= 0.1.2)
|
30
|
+
cucumber-core (1.5.0)
|
31
|
+
gherkin (~> 4.0)
|
32
|
+
cucumber-wire (0.0.1)
|
10
33
|
diff-lcs (1.3)
|
34
|
+
ffi (1.9.18)
|
35
|
+
gherkin (4.1.1)
|
36
|
+
method_source (0.8.2)
|
37
|
+
multi_json (1.12.1)
|
38
|
+
multi_test (0.1.2)
|
39
|
+
pry (0.10.4)
|
40
|
+
coderay (~> 1.1.0)
|
41
|
+
method_source (~> 0.8.1)
|
42
|
+
slop (~> 3.4)
|
11
43
|
rake (10.5.0)
|
12
44
|
rspec (3.5.0)
|
13
45
|
rspec-core (~> 3.5.0)
|
@@ -22,14 +54,17 @@ GEM
|
|
22
54
|
diff-lcs (>= 1.2.0, < 2.0)
|
23
55
|
rspec-support (~> 3.5.0)
|
24
56
|
rspec-support (3.5.0)
|
57
|
+
slop (3.6.0)
|
25
58
|
thor (0.19.4)
|
26
59
|
|
27
60
|
PLATFORMS
|
28
61
|
ruby
|
29
62
|
|
30
63
|
DEPENDENCIES
|
64
|
+
aruba
|
31
65
|
bundler (~> 1.13)
|
32
66
|
htcht!
|
67
|
+
pry
|
33
68
|
rake (~> 10.0)
|
34
69
|
rspec (~> 3.5)
|
35
70
|
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Htcht
|
2
|
+
[](https://badge.fury.io/rb/htcht)
|
2
3
|
|
3
4
|
The internal CLI of Trim Agency. Used to setup new projects, build, test, etc.
|
4
5
|
|
@@ -16,9 +17,9 @@ Run ```htcht help``` for a list of commands.
|
|
16
17
|
|
17
18
|
## Development
|
18
19
|
|
19
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `
|
20
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `rspec` to run the test suite.
|
20
21
|
|
21
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
22
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
22
23
|
|
23
24
|
## Contributing
|
24
25
|
|
data/htcht.gemspec
CHANGED
@@ -34,4 +34,6 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "bundler", "~> 1.13"
|
35
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.5"
|
37
|
+
spec.add_development_dependency "aruba"
|
38
|
+
spec.add_development_dependency "pry"
|
37
39
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
FROM ruby:
|
1
|
+
FROM ruby:set_ruby_version
|
2
2
|
MAINTAINER stevetwitte@gmail.com
|
3
3
|
|
4
4
|
RUN apt-get update && apt-get install -y \
|
@@ -14,7 +14,7 @@ ENV LC_ALL en_US.UTF-8
|
|
14
14
|
RUN mkdir -p /app
|
15
15
|
WORKDIR /app
|
16
16
|
|
17
|
-
RUN gem install rails
|
17
|
+
RUN gem install rails --version set_rails_version
|
18
18
|
#COPY Gemfile Gemfile.lock ./
|
19
19
|
#RUN gem install bundler && bundle install --jobs 20 --retry 5
|
20
20
|
|
@@ -1,9 +1,16 @@
|
|
1
|
+
require 'htcht/helpers/general_helpers'
|
2
|
+
require 'htcht/helpers/name_helpers'
|
3
|
+
require 'htcht/helpers/version_helpers'
|
4
|
+
|
1
5
|
module Htcht
|
2
6
|
module CLI
|
3
7
|
module Rails
|
4
8
|
|
5
9
|
class Rails < Thor
|
6
10
|
include Thor::Actions
|
11
|
+
include Htcht::Helpers::GeneralHelpers
|
12
|
+
include Htcht::Helpers::NameHelpers
|
13
|
+
include Htcht::Helpers::VersionHelpers
|
7
14
|
|
8
15
|
def self.source_root
|
9
16
|
File.dirname(__FILE__)
|
@@ -14,23 +21,27 @@ module Htcht
|
|
14
21
|
method_option :api, type: :boolean, default: false, :aliases => '-a', :desc => 'default: [--no-api] Generate Rails App in API mode.'
|
15
22
|
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
23
|
method_option :test, type: :boolean, default: false, :desc => 'default: [--no-test]'
|
24
|
+
method_option :ruby_version, type: :string, :desc => "default: [latest version] Set the version of Ruby to be used."
|
25
|
+
method_option :rails_version, type: :string, :desc => "default: [latest version] Set the version of Rails to be used."
|
17
26
|
def new(appname)
|
27
|
+
unless docker_running?
|
28
|
+
puts 'Check that Docker is installed and running'
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
options[:ruby_version] ||= latest_ruby
|
33
|
+
options[:rails_version] ||= latest_rails
|
18
34
|
|
19
35
|
# Format the appname as snake case for folders, etc.
|
20
|
-
|
21
|
-
# TODO: Move to a helper file
|
22
|
-
snake_name = appname.gsub(/::/, '/').
|
23
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
24
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
25
|
-
tr("-", "_").
|
26
|
-
downcase
|
36
|
+
snake_name = snake_casify(appname)
|
27
37
|
|
28
38
|
rails_new_command = 'docker-compose run app rails new . --database=postgresql --skip-bundle'
|
29
39
|
|
30
40
|
# Set the application template
|
31
41
|
# TODO: Refactor to be dynamic from a directory
|
32
42
|
if options[:init] && options[:api]
|
33
|
-
|
43
|
+
template_path = "#{snake_name}/api_init_template.rb"
|
44
|
+
copy_file('templates/api_init_template.rb', template_path)
|
34
45
|
copy_file('templates/api_build_files/user_spec.rb', "#{snake_name}/build_files/user_spec.rb")
|
35
46
|
copy_file('templates/api_build_files/users.rb', "#{snake_name}/build_files/users.rb")
|
36
47
|
copy_file('templates/api_build_files/email_validator.rb', "#{snake_name}/build_files/email_validator.rb")
|
@@ -38,15 +49,23 @@ module Htcht
|
|
38
49
|
copy_file('templates/api_build_files/shoulda_matchers.rb', "#{snake_name}/build_files/shoulda_matchers.rb")
|
39
50
|
copy_file('templates/api_build_files/rails_helper.rb', "#{snake_name}/build_files/rails_helper.rb")
|
40
51
|
copy_file('templates/api_build_files/seeds.rb', "#{snake_name}/build_files/seeds.rb")
|
52
|
+
copy_file('templates/api_build_files/active_model_serializers.rb', "#{snake_name}/build_files/active_model_serializers.rb")
|
41
53
|
rails_new_command.concat(' -m api_init_template.rb -T')
|
42
54
|
elsif options[:init]
|
43
55
|
puts "--init must be used with --api for now."
|
44
56
|
return
|
45
57
|
else
|
46
|
-
|
58
|
+
template_path = "#{snake_name}/default_template.rb"
|
59
|
+
copy_file 'templates/default_template.rb', template_path
|
47
60
|
rails_new_command.concat(' -m default_template.rb')
|
48
61
|
end
|
49
62
|
|
63
|
+
if defined? template_path
|
64
|
+
add_app_names_to_template(path: template_path,
|
65
|
+
appname: appname,
|
66
|
+
snake_name: snake_name)
|
67
|
+
end
|
68
|
+
|
50
69
|
# Copy this over so that Docker can run Rails new
|
51
70
|
copy_file 'BaseGemfile', "#{snake_name}/Gemfile"
|
52
71
|
rails_new_command.concat(' --force')
|
@@ -70,6 +89,11 @@ module Htcht
|
|
70
89
|
empty_directory(snake_name)
|
71
90
|
copy_file('docker-compose.yml', "#{snake_name}/docker-compose.yml")
|
72
91
|
copy_file('Dockerfile', "#{snake_name}/Dockerfile")
|
92
|
+
gsub_file("#{snake_name}/Dockerfile", 'set_ruby_version', options[:ruby_version])
|
93
|
+
gsub_file("#{snake_name}/Dockerfile", 'set_rails_version', options[:rails_version])
|
94
|
+
gsub_file("#{snake_name}/Gemfile", 'set_ruby_version', options[:ruby_version])
|
95
|
+
gsub_file("#{snake_name}/Gemfile", 'set_rails_version', options[:rails_version])
|
96
|
+
|
73
97
|
|
74
98
|
inside(snake_name) do
|
75
99
|
|
@@ -80,7 +104,7 @@ module Htcht
|
|
80
104
|
run(rails_new_command)
|
81
105
|
|
82
106
|
# Edit the Dockerfile and rebuild the app now that it has a Gemfile and Gemfile.lock
|
83
|
-
gsub_file('Dockerfile',
|
107
|
+
gsub_file('Dockerfile', "RUN gem install rails", '#RUN gem install rails')
|
84
108
|
gsub_file('Dockerfile', '#COPY Gemfile Gemfile.lock ./', 'COPY Gemfile Gemfile.lock ./')
|
85
109
|
gsub_file('Dockerfile', '#RUN gem install bundler && bundle install --jobs 20 --retry 5', 'RUN gem install bundler && bundle install --jobs 20 --retry 5')
|
86
110
|
run('docker-compose build')
|
@@ -96,10 +120,15 @@ module Htcht
|
|
96
120
|
remove_file("default_template.rb")
|
97
121
|
end
|
98
122
|
end
|
123
|
+
end
|
99
124
|
|
125
|
+
private
|
126
|
+
|
127
|
+
def add_app_names_to_template(path:, appname:, snake_name:)
|
128
|
+
gsub_file(path, 'set_appname', appname)
|
129
|
+
gsub_file(path, 'set_snake_name', snake_name)
|
100
130
|
end
|
101
131
|
end
|
102
132
|
end
|
103
|
-
|
104
133
|
end
|
105
134
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
ActiveModelSerializers.config.adapter = :json
|
@@ -45,18 +45,8 @@ end
|
|
45
45
|
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
46
46
|
|
47
47
|
# Setup the app config
|
48
|
-
|
49
|
-
|
50
|
-
# ----------------------------
|
51
|
-
|
52
|
-
puts '**********'
|
53
|
-
puts
|
54
|
-
appname = ask("What should we call this new app? (CamelCasePlease)")
|
55
|
-
snake_name = appname.gsub(/::/, '/').
|
56
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
57
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
58
|
-
tr("-", "_").
|
59
|
-
downcase
|
48
|
+
appname = "set_appname"
|
49
|
+
snake_name = "set_snake_name"
|
60
50
|
|
61
51
|
# Set the name of the app in application.rb
|
62
52
|
gsub_file('config/application.rb', 'module App', "module #{appname}")
|
@@ -124,6 +114,7 @@ copy_file('build_files/factory_girl.rb', 'spec/support/factory_girl.rb')
|
|
124
114
|
copy_file('build_files/rails_helper.rb', 'spec/rails_helper.rb')
|
125
115
|
copy_file('build_files/shoulda_matchers.rb', 'spec/support/shoulda_matchers.rb')
|
126
116
|
copy_file('build_files/seeds.rb', 'db/seeds.rb')
|
117
|
+
copy_file('build_files/active_model_serializers.rb', 'config/initializers/active_model_serializers.rb')
|
127
118
|
empty_directory('db/seeds')
|
128
119
|
empty_directory('db/seeds/development')
|
129
120
|
empty_directory('db/seeds/test')
|
@@ -7,18 +7,8 @@ end
|
|
7
7
|
gem 'pg'
|
8
8
|
|
9
9
|
# Setup the app config
|
10
|
-
|
11
|
-
|
12
|
-
# ----------------------------
|
13
|
-
|
14
|
-
puts '**********'
|
15
|
-
puts
|
16
|
-
appname = ask("What should we call this new app? (CamelCasePlease)")
|
17
|
-
snake_name = appname.gsub(/::/, '/').
|
18
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
19
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
20
|
-
tr("-", "_").
|
21
|
-
downcase
|
10
|
+
appname = "set_appname"
|
11
|
+
snake_name = "set_snake_name"
|
22
12
|
|
23
13
|
# Set the name of the app in application.rb
|
24
14
|
gsub_file('config/application.rb', 'module App', "module #{appname}")
|
@@ -32,4 +22,3 @@ gsub_file('config/database.yml', 'username: app', "username: #{snake_name}")
|
|
32
22
|
gsub_file('config/database.yml', 'APP_DATABASE_PASSWORD', "#{snake_name.upcase}_DATABASE_PASSWORD")
|
33
23
|
|
34
24
|
run('bundle install')
|
35
|
-
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Htcht
|
2
|
+
module Helpers
|
3
|
+
module NameHelpers
|
4
|
+
|
5
|
+
def snake_casify(name)
|
6
|
+
name.gsub(/::/, '/').
|
7
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
8
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
9
|
+
gsub(/\s+/, '_').
|
10
|
+
tr("-", "_").
|
11
|
+
downcase
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Htcht
|
2
|
+
module Helpers
|
3
|
+
module VersionHelpers
|
4
|
+
|
5
|
+
def latest_ruby
|
6
|
+
# This is going to be hard coded for now because I can't seem to
|
7
|
+
# find a public api for getting the latest version of Ruby
|
8
|
+
'2.4.1'
|
9
|
+
end
|
10
|
+
|
11
|
+
def latest_rails
|
12
|
+
# The rubygems.org API does allow you to get the latest version
|
13
|
+
# of Rails but it is a private api (see above comment as well)
|
14
|
+
'5.0.2'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/lib/htcht/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.3
|
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-
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aruba
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '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'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description:
|
70
98
|
email:
|
71
99
|
- info@trimagency.com
|
@@ -90,6 +118,7 @@ files:
|
|
90
118
|
- lib/htcht/cli/rails/Dockerfile
|
91
119
|
- lib/htcht/cli/rails/docker-compose.yml
|
92
120
|
- lib/htcht/cli/rails/rails.rb
|
121
|
+
- lib/htcht/cli/rails/templates/api_build_files/active_model_serializers.rb
|
93
122
|
- lib/htcht/cli/rails/templates/api_build_files/email_validator.rb
|
94
123
|
- lib/htcht/cli/rails/templates/api_build_files/factory_girl.rb
|
95
124
|
- lib/htcht/cli/rails/templates/api_build_files/rails_helper.rb
|
@@ -99,6 +128,9 @@ files:
|
|
99
128
|
- lib/htcht/cli/rails/templates/api_build_files/users.rb
|
100
129
|
- lib/htcht/cli/rails/templates/api_init_template.rb
|
101
130
|
- lib/htcht/cli/rails/templates/default_template.rb
|
131
|
+
- lib/htcht/helpers/general_helpers.rb
|
132
|
+
- lib/htcht/helpers/name_helpers.rb
|
133
|
+
- lib/htcht/helpers/version_helpers.rb
|
102
134
|
- lib/htcht/main.rb
|
103
135
|
- lib/htcht/version.rb
|
104
136
|
homepage: https://github.com/TrimAgency/htcht
|