htcht 0.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 +7 -0
- data/.gitignore +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/htcht +5 -0
- data/bin/setup +8 -0
- data/htcht.gemspec +37 -0
- data/lib/htcht/cli/rails/BaseGemfile +5 -0
- data/lib/htcht/cli/rails/Dockerfile +25 -0
- data/lib/htcht/cli/rails/docker-compose.yml +13 -0
- data/lib/htcht/cli/rails/rails.rb +95 -0
- data/lib/htcht/cli/rails/templates/api_bootstrap_template.rb +117 -0
- data/lib/htcht/cli/rails/templates/api_build_files/email_validator.rb +15 -0
- data/lib/htcht/cli/rails/templates/api_build_files/factory_girl.rb +3 -0
- data/lib/htcht/cli/rails/templates/api_build_files/rails_helper.rb +42 -0
- data/lib/htcht/cli/rails/templates/api_build_files/shoulda_matchers.rb +13 -0
- data/lib/htcht/cli/rails/templates/api_build_files/user_spec.rb +47 -0
- data/lib/htcht/cli/rails/templates/api_build_files/users.rb +7 -0
- data/lib/htcht/cli/rails/templates/default_template.rb +35 -0
- data/lib/htcht/main.rb +14 -0
- data/lib/htcht/version.rb +3 -0
- data/lib/htcht.rb +5 -0
- metadata +129 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d1cd0938dd3865ec3f78ada3ab31fefc2cf787e3
|
|
4
|
+
data.tar.gz: 9b31904115879870d955d83f26dd68e1275c137e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5b90731d79df2cc8d8909a36de66743fc95716b9e0a71ae95015f17994b5afb5646442e2d08d235243fb0baff9cffe149880dac2d7de7729aa24955c3200dd69
|
|
7
|
+
data.tar.gz: 616b60ba20f6c299e04c328a91e7e32b7fc81c1e0bb3cf657c514f0db5f63b3be93982784ab7692d2b6cc3a4ca7fae912430145aa5999cf066e9d23805ccb011
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at stevetwitte@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
htcht (0.1.0)
|
|
5
|
+
thor
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
rake (10.5.0)
|
|
12
|
+
rspec (3.5.0)
|
|
13
|
+
rspec-core (~> 3.5.0)
|
|
14
|
+
rspec-expectations (~> 3.5.0)
|
|
15
|
+
rspec-mocks (~> 3.5.0)
|
|
16
|
+
rspec-core (3.5.4)
|
|
17
|
+
rspec-support (~> 3.5.0)
|
|
18
|
+
rspec-expectations (3.5.0)
|
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
20
|
+
rspec-support (~> 3.5.0)
|
|
21
|
+
rspec-mocks (3.5.0)
|
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
23
|
+
rspec-support (~> 3.5.0)
|
|
24
|
+
rspec-support (3.5.0)
|
|
25
|
+
thor (0.19.4)
|
|
26
|
+
|
|
27
|
+
PLATFORMS
|
|
28
|
+
ruby
|
|
29
|
+
|
|
30
|
+
DEPENDENCIES
|
|
31
|
+
bundler (~> 1.13)
|
|
32
|
+
htcht!
|
|
33
|
+
rake (~> 10.0)
|
|
34
|
+
rspec (~> 3.5)
|
|
35
|
+
|
|
36
|
+
BUNDLED WITH
|
|
37
|
+
1.14.3
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Stephen Taylor Witte
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Htcht
|
|
2
|
+
|
|
3
|
+
The internal CLI of Trim Agency. Used to setup new projects, build, test, etc.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Run this command to install
|
|
8
|
+
|
|
9
|
+
$ gem install htcht
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Run ```htcht help``` for a list of commands.
|
|
14
|
+
|
|
15
|
+
## Development
|
|
16
|
+
|
|
17
|
+
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 `rake` to run the test suite.
|
|
18
|
+
|
|
19
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
20
|
+
|
|
21
|
+
## Contributing
|
|
22
|
+
|
|
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.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
29
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "htcht"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/htcht
ADDED
data/bin/setup
ADDED
data/htcht.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'htcht/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "htcht"
|
|
8
|
+
spec.version = Htcht::VERSION
|
|
9
|
+
spec.authors = ["Trim Agency"]
|
|
10
|
+
spec.email = ["info@trimagency.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{The internal CLI of Trim Agency. Used to setup new projects, build, test, etc.}
|
|
13
|
+
spec.homepage = "https://github.com/TrimAgency/htcht"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
20
|
+
else
|
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
22
|
+
"public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = "bin"
|
|
29
|
+
spec.executables = ["htcht"]
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_dependency "thor", "~> 0.1"
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
|
37
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
FROM ruby:2.3.3
|
|
2
|
+
MAINTAINER stevetwitte@gmail.com
|
|
3
|
+
|
|
4
|
+
RUN apt-get update && apt-get install -y \
|
|
5
|
+
build-essential \
|
|
6
|
+
locales \
|
|
7
|
+
nodejs
|
|
8
|
+
|
|
9
|
+
RUN locale-gen en_US.UTF-8
|
|
10
|
+
ENV LANG en_US.UTF-8
|
|
11
|
+
ENV LANGUAGE en_US:en
|
|
12
|
+
ENV LC_ALL en_US.UTF-8
|
|
13
|
+
|
|
14
|
+
RUN mkdir -p /app
|
|
15
|
+
WORKDIR /app
|
|
16
|
+
|
|
17
|
+
RUN gem install rails
|
|
18
|
+
#COPY Gemfile Gemfile.lock ./
|
|
19
|
+
#RUN gem install bundler && bundle install --jobs 20 --retry 5
|
|
20
|
+
|
|
21
|
+
COPY . ./
|
|
22
|
+
|
|
23
|
+
EXPOSE 3000
|
|
24
|
+
|
|
25
|
+
CMD ["rm", "-f", "tmp/pids/server.pid", "&&", "bundle", "exec", "rails", "s", "-b", "0.0.0.0", "-p", "3000"]
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
module Htcht
|
|
2
|
+
module CLI
|
|
3
|
+
module Rails
|
|
4
|
+
|
|
5
|
+
class Rails < Thor
|
|
6
|
+
include Thor::Actions
|
|
7
|
+
|
|
8
|
+
def self.source_root
|
|
9
|
+
File.dirname(__FILE__)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc 'new AppName', 'Create a new base Rails App inside a Docker Container with Postgres setup as the database.'
|
|
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).'
|
|
16
|
+
method_option :test, type: :boolean, default: false, :desc => 'default: [--no-test]'
|
|
17
|
+
def new(appname)
|
|
18
|
+
|
|
19
|
+
# Format the appname as snake case for folders, etc.
|
|
20
|
+
# This code is taken straight from Rails
|
|
21
|
+
snake_name = appname.gsub(/::/, '/').
|
|
22
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
23
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
24
|
+
tr("-", "_").
|
|
25
|
+
downcase
|
|
26
|
+
|
|
27
|
+
rails_new_command = 'docker-compose run app rails new . --database=postgresql -T --skip-bundle'
|
|
28
|
+
|
|
29
|
+
# Set the application template
|
|
30
|
+
# 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")
|
|
33
|
+
copy_file('templates/api_build_files/user_spec.rb', "#{snake_name}/build_files/user_spec.rb")
|
|
34
|
+
copy_file('templates/api_build_files/users.rb', "#{snake_name}/build_files/users.rb")
|
|
35
|
+
copy_file('templates/api_build_files/email_validator.rb', "#{snake_name}/build_files/email_validator.rb")
|
|
36
|
+
copy_file('templates/api_build_files/factory_girl.rb', "#{snake_name}/build_files/factory_girl.rb")
|
|
37
|
+
copy_file('templates/api_build_files/shoulda_matchers.rb', "#{snake_name}/build_files/shoulda_matchers.rb")
|
|
38
|
+
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"
|
|
42
|
+
return
|
|
43
|
+
else
|
|
44
|
+
copy_file 'templates/default_template.rb', "#{snake_name}/default_template.rb"
|
|
45
|
+
rails_new_command.concat(' -m default_template.rb')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Copy this over so that Docker can run Rails new
|
|
49
|
+
copy_file 'BaseGemfile', "#{snake_name}/Gemfile"
|
|
50
|
+
rails_new_command.concat(' --force')
|
|
51
|
+
|
|
52
|
+
if options[:api]
|
|
53
|
+
rails_new_command.concat(' --api')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
unless options[:verbose]
|
|
57
|
+
rails_new_command.concat(' --quiet')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
puts "Creating new Rails API with name: #{appname}"
|
|
61
|
+
|
|
62
|
+
if options[:test]
|
|
63
|
+
puts "Here is the command:"
|
|
64
|
+
puts rails_new_command
|
|
65
|
+
return
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
empty_directory(snake_name)
|
|
69
|
+
copy_file('docker-compose.yml', "#{snake_name}/docker-compose.yml")
|
|
70
|
+
copy_file('Dockerfile', "#{snake_name}/Dockerfile")
|
|
71
|
+
|
|
72
|
+
inside(snake_name) do
|
|
73
|
+
|
|
74
|
+
# Build the containers
|
|
75
|
+
run('docker-compse build')
|
|
76
|
+
|
|
77
|
+
# Run the command to generate a new rails app
|
|
78
|
+
run(rails_new_command)
|
|
79
|
+
|
|
80
|
+
# Edit the Dockerfile and rebuild the app now that it has a Gemfile and Gemfile.lock
|
|
81
|
+
gsub_file('Dockerfile', 'RUN gem install rails', '#RUN gem install rails')
|
|
82
|
+
gsub_file('Dockerfile', '#COPY Gemfile Gemfile.lock ./', 'COPY Gemfile Gemfile.lock ./')
|
|
83
|
+
gsub_file('Dockerfile', '#RUN gem install bundler && bundle install --jobs 20 --retry 5', 'RUN gem install bundler && bundle install --jobs 20 --retry 5')
|
|
84
|
+
run('docker-compose build')
|
|
85
|
+
|
|
86
|
+
run('docker-compose run app rake db:create')
|
|
87
|
+
run('docker-compose run app rake db:migrate')
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
def source_paths
|
|
2
|
+
[File.expand_path(File.dirname(__FILE__))]
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
# Install Gems
|
|
6
|
+
# ----------------------------
|
|
7
|
+
gem 'rails'
|
|
8
|
+
gem 'pg'
|
|
9
|
+
gem 'puma'
|
|
10
|
+
gem 'bcrypt'
|
|
11
|
+
gem 'rack-cors'
|
|
12
|
+
gem 'active_model_serializers'
|
|
13
|
+
gem 'jwt'
|
|
14
|
+
gem 'knock'
|
|
15
|
+
gem 'seedbank'
|
|
16
|
+
gem 'figaro'
|
|
17
|
+
|
|
18
|
+
gem_group :development, :test do
|
|
19
|
+
gem 'byebug', platform: :mri
|
|
20
|
+
gem 'rspec-rails'
|
|
21
|
+
gem 'faker'
|
|
22
|
+
gem 'pry'
|
|
23
|
+
gem 'pry-byebug'
|
|
24
|
+
gem 'pry-clipboard'
|
|
25
|
+
gem 'pry-doc'
|
|
26
|
+
gem 'pry-docmore'
|
|
27
|
+
gem 'pry-rescue'
|
|
28
|
+
gem 'pry-stack_explorer'
|
|
29
|
+
gem 'pry-rails'
|
|
30
|
+
gem 'shoulda-matchers'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
gem_group :development do
|
|
34
|
+
gem 'listen'
|
|
35
|
+
gem 'spring'
|
|
36
|
+
gem 'spring-watcher-listen'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
gem_group :test do
|
|
40
|
+
gem 'simplecov', :require => false
|
|
41
|
+
gem 'factory_girl_rails'
|
|
42
|
+
gem 'database_cleaner'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|
46
|
+
|
|
47
|
+
# Setup the app config
|
|
48
|
+
# But get the name first
|
|
49
|
+
# TODO: Possible refactor (should be able to get the name from the gem?)
|
|
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
|
|
60
|
+
|
|
61
|
+
# Set the name of the app in application.rb
|
|
62
|
+
gsub_file('config/application.rb', 'module App', "module #{appname}")
|
|
63
|
+
|
|
64
|
+
# Edit database.yml to work with docker
|
|
65
|
+
insert_into_file('config/database.yml', "\s\susername: postgres\n\s\spassword:\n\s\shost: postgres\n\s\sport: 5432\n", :after => "default: &default\n")
|
|
66
|
+
gsub_file('config/database.yml', 'app_development', "#{snake_name}_development")
|
|
67
|
+
gsub_file('config/database.yml', 'app_test', "#{snake_name}_test")
|
|
68
|
+
gsub_file('config/database.yml', 'app_production', "#{snake_name}_production")
|
|
69
|
+
gsub_file('config/database.yml', 'username: app', "username: #{snake_name}")
|
|
70
|
+
gsub_file('config/database.yml', 'APP_DATABASE_PASSWORD', "#{snake_name.upcase}_DATABASE_PASSWORD")
|
|
71
|
+
|
|
72
|
+
run('bundle install')
|
|
73
|
+
|
|
74
|
+
# Setup Rspec for Testing
|
|
75
|
+
# ----------------------------
|
|
76
|
+
|
|
77
|
+
run('rails generate rspec:install')
|
|
78
|
+
|
|
79
|
+
# Generate User Model
|
|
80
|
+
# and add validations to user.rb
|
|
81
|
+
# ----------------------------
|
|
82
|
+
|
|
83
|
+
generate(:model, 'User', 'email:uniq:index', 'password:digest')
|
|
84
|
+
user_migration = Dir.glob('db/migrate/*.rb')[0].to_s
|
|
85
|
+
gsub_file(user_migration, 't.string :email', 't.string :email, null: false')
|
|
86
|
+
gsub_file(user_migration, 't.string :password_digest', 't.string :password_digest, null: false')
|
|
87
|
+
|
|
88
|
+
insert_into_file('app/models/user.rb', after: 'has_secure_password') do
|
|
89
|
+
%q(
|
|
90
|
+
|
|
91
|
+
validates :email,
|
|
92
|
+
uniqueness: { case_sensitive: false },
|
|
93
|
+
presence: true,
|
|
94
|
+
email: true
|
|
95
|
+
|
|
96
|
+
validates :password,
|
|
97
|
+
length: { minimum: 8 },
|
|
98
|
+
confirmation: true
|
|
99
|
+
|
|
100
|
+
validates :password_confirmation,
|
|
101
|
+
presence: true
|
|
102
|
+
|
|
103
|
+
def generate_token
|
|
104
|
+
Knock::AuthToken.new(payload: { sub: id }).token
|
|
105
|
+
end
|
|
106
|
+
)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
remove_file('spec/models/user_spec.rb')
|
|
110
|
+
copy_file('build_files/user_spec.rb', 'spec/models/user_spec.rb')
|
|
111
|
+
copy_file('build_files/users.rb', 'spec/factories/users.rb')
|
|
112
|
+
copy_file('build_files/email_validator.rb', 'app/validators/email_validator.rb')
|
|
113
|
+
copy_file('build_files/factory_girl.rb', 'spec/support/factory_girl.rb')
|
|
114
|
+
copy_file('build_files/rails_helper.rb', 'spec/rails_helper.rb')
|
|
115
|
+
copy_file('build_files/shoulda_matchers.rb', 'spec/support/shoulda_matchers.rb')
|
|
116
|
+
remove_dir('build_files/')
|
|
117
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class EmailValidator < ActiveModel::EachValidator
|
|
2
|
+
VALID_EMAIL_REGEX = %r(\A[^@]+@(?:[^@]+\.)+[^@.]+\z)
|
|
3
|
+
|
|
4
|
+
def validate_each(record, attribute, value)
|
|
5
|
+
unless value =~ VALID_EMAIL_REGEX
|
|
6
|
+
record.errors.add(attribute, error_message)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def error_message
|
|
13
|
+
options.fetch(:messages, :invalid)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
3
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
4
|
+
# Prevent database truncation if the environment is production
|
|
5
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
require 'rspec/rails'
|
|
8
|
+
|
|
9
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
10
|
+
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
|
11
|
+
|
|
12
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
13
|
+
RSpec.configure do |config|
|
|
14
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
15
|
+
#
|
|
16
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
17
|
+
|
|
18
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
19
|
+
# examples within a transaction, remove the following line or assign false
|
|
20
|
+
# instead of true.
|
|
21
|
+
config.use_transactional_fixtures = true
|
|
22
|
+
|
|
23
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
|
24
|
+
# based on their file location, for example enabling you to call `get` and
|
|
25
|
+
# `post` in specs under `spec/controllers`.
|
|
26
|
+
#
|
|
27
|
+
# You can disable this behaviour by removing the line below, and instead
|
|
28
|
+
# explicitly tag your specs with their type, e.g.:
|
|
29
|
+
#
|
|
30
|
+
# RSpec.describe UsersController, :type => :controller do
|
|
31
|
+
# # ...
|
|
32
|
+
# end
|
|
33
|
+
#
|
|
34
|
+
# The different available types are documented in the features, such as in
|
|
35
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
|
36
|
+
config.infer_spec_type_from_file_location!
|
|
37
|
+
|
|
38
|
+
# Filter lines from Rails gems in backtraces.
|
|
39
|
+
config.filter_rails_from_backtrace!
|
|
40
|
+
# arbitrary gems may also be filtered via:
|
|
41
|
+
# config.filter_gems_from_backtrace("gem name")
|
|
42
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Shoulda::Matchers.configure do |config|
|
|
2
|
+
config.integrate do |with|
|
|
3
|
+
# Choose a test framework:
|
|
4
|
+
with.test_framework :rspec
|
|
5
|
+
|
|
6
|
+
# Choose one or more libraries:
|
|
7
|
+
with.library :active_record
|
|
8
|
+
with.library :active_model
|
|
9
|
+
with.library :action_controller
|
|
10
|
+
# Or, choose the following (which implies all of the above):
|
|
11
|
+
with.library :rails
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe User, type: :model do
|
|
4
|
+
subject { build :user }
|
|
5
|
+
|
|
6
|
+
it "has a valid factory" do
|
|
7
|
+
expect(build :user).to be_valid
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "validations" do
|
|
11
|
+
it { is_expected.to have_secure_password }
|
|
12
|
+
|
|
13
|
+
it { is_expected.to validate_uniqueness_of(:email).case_insensitive }
|
|
14
|
+
|
|
15
|
+
it { is_expected.to validate_presence_of(:email) }
|
|
16
|
+
|
|
17
|
+
it { is_expected.to validate_confirmation_of(:password) }
|
|
18
|
+
|
|
19
|
+
it { is_expected.to validate_length_of(:password).is_at_least(8) }
|
|
20
|
+
|
|
21
|
+
it { is_expected.to validate_presence_of(:password_confirmation) }
|
|
22
|
+
|
|
23
|
+
describe "email" do
|
|
24
|
+
before do
|
|
25
|
+
subject.email = email
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "with a bad email address" do
|
|
29
|
+
let(:email) { "bademail" }
|
|
30
|
+
|
|
31
|
+
it { is_expected.to be_invalid }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "with a bad email address containing an ampersand" do
|
|
35
|
+
let(:email) { "bad@email" }
|
|
36
|
+
|
|
37
|
+
it { is_expected.to be_invalid }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "with a good email address" do
|
|
41
|
+
let(:email) { "bad@email.example.com" }
|
|
42
|
+
|
|
43
|
+
it { is_expected.to be_valid }
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
def source_paths
|
|
2
|
+
[File.expand_path(File.dirname(__FILE__))]
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
# Install Gems
|
|
6
|
+
# ----------------------------
|
|
7
|
+
gem 'pg'
|
|
8
|
+
|
|
9
|
+
# Setup the app config
|
|
10
|
+
# But get the name first
|
|
11
|
+
# TODO: Possible refactor (should be able to get the name from the gem?)
|
|
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
|
|
22
|
+
|
|
23
|
+
# Set the name of the app in application.rb
|
|
24
|
+
gsub_file('config/application.rb', 'module App', "module #{appname}")
|
|
25
|
+
|
|
26
|
+
# Edit database.yml to work with docker
|
|
27
|
+
insert_into_file('config/database.yml', "\s\susername: postgres\n\s\spassword:\n\s\shost: postgres\n\s\sport: 5432\n", :after => "default: &default\n")
|
|
28
|
+
gsub_file('config/database.yml', 'app_development', "#{snake_name}_development")
|
|
29
|
+
gsub_file('config/database.yml', 'app_test', "#{snake_name}_test")
|
|
30
|
+
gsub_file('config/database.yml', 'app_production', "#{snake_name}_production")
|
|
31
|
+
gsub_file('config/database.yml', 'username: app', "username: #{snake_name}")
|
|
32
|
+
gsub_file('config/database.yml', 'APP_DATABASE_PASSWORD', "#{snake_name.upcase}_DATABASE_PASSWORD")
|
|
33
|
+
|
|
34
|
+
run('bundle install')
|
|
35
|
+
|
data/lib/htcht/main.rb
ADDED
data/lib/htcht.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: htcht
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Trim Agency
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-03-18 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.1'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.1'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.13'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.13'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.5'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.5'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- info@trimagency.com
|
|
72
|
+
executables:
|
|
73
|
+
- htcht
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- CODE_OF_CONDUCT.md
|
|
79
|
+
- Gemfile
|
|
80
|
+
- Gemfile.lock
|
|
81
|
+
- LICENSE.txt
|
|
82
|
+
- README.md
|
|
83
|
+
- Rakefile
|
|
84
|
+
- bin/console
|
|
85
|
+
- bin/htcht
|
|
86
|
+
- bin/setup
|
|
87
|
+
- htcht.gemspec
|
|
88
|
+
- lib/htcht.rb
|
|
89
|
+
- lib/htcht/cli/rails/BaseGemfile
|
|
90
|
+
- lib/htcht/cli/rails/Dockerfile
|
|
91
|
+
- lib/htcht/cli/rails/docker-compose.yml
|
|
92
|
+
- lib/htcht/cli/rails/rails.rb
|
|
93
|
+
- lib/htcht/cli/rails/templates/api_bootstrap_template.rb
|
|
94
|
+
- lib/htcht/cli/rails/templates/api_build_files/email_validator.rb
|
|
95
|
+
- lib/htcht/cli/rails/templates/api_build_files/factory_girl.rb
|
|
96
|
+
- lib/htcht/cli/rails/templates/api_build_files/rails_helper.rb
|
|
97
|
+
- lib/htcht/cli/rails/templates/api_build_files/shoulda_matchers.rb
|
|
98
|
+
- lib/htcht/cli/rails/templates/api_build_files/user_spec.rb
|
|
99
|
+
- lib/htcht/cli/rails/templates/api_build_files/users.rb
|
|
100
|
+
- lib/htcht/cli/rails/templates/default_template.rb
|
|
101
|
+
- lib/htcht/main.rb
|
|
102
|
+
- lib/htcht/version.rb
|
|
103
|
+
homepage: https://github.com/TrimAgency/htcht
|
|
104
|
+
licenses:
|
|
105
|
+
- MIT
|
|
106
|
+
metadata:
|
|
107
|
+
allowed_push_host: https://rubygems.org
|
|
108
|
+
post_install_message:
|
|
109
|
+
rdoc_options: []
|
|
110
|
+
require_paths:
|
|
111
|
+
- lib
|
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
|
+
requirements:
|
|
119
|
+
- - ">="
|
|
120
|
+
- !ruby/object:Gem::Version
|
|
121
|
+
version: '0'
|
|
122
|
+
requirements: []
|
|
123
|
+
rubyforge_project:
|
|
124
|
+
rubygems_version: 2.5.1
|
|
125
|
+
signing_key:
|
|
126
|
+
specification_version: 4
|
|
127
|
+
summary: The internal CLI of Trim Agency. Used to setup new projects, build, test,
|
|
128
|
+
etc.
|
|
129
|
+
test_files: []
|