sumcli 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 +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +144 -0
- data/LICENSE.txt +20 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +2 -0
- data/exe/sumcli +18 -0
- data/lib/sumcli/cli.rb +37 -0
- data/lib/sumcli/command.rb +121 -0
- data/lib/sumcli/commands/.gitkeep +1 -0
- data/lib/sumcli/commands/add/service.rb +30 -0
- data/lib/sumcli/commands/add.rb +24 -0
- data/lib/sumcli/commands/g/endpoint.rb +69 -0
- data/lib/sumcli/commands/g.rb +24 -0
- data/lib/sumcli/commands/new.rb +25 -0
- data/lib/sumcli/templates/.gitkeep +1 -0
- data/lib/sumcli/templates/add/service/.gitkeep +1 -0
- data/lib/sumcli/templates/g/endpoint/.gitkeep +1 -0
- data/lib/sumcli/templates/g/endpoint/entity.rb.erb +7 -0
- data/lib/sumcli/templates/g/endpoint/new.rb.erb +8 -0
- data/lib/sumcli/templates/g/endpoint/test.rb.erb +19 -0
- data/lib/sumcli/templates/new/.gitkeep +1 -0
- data/lib/sumcli/templates/new/app/.editorconfig +12 -0
- data/lib/sumcli/templates/new/app/.gitignore +9 -0
- data/lib/sumcli/templates/new/app/.rspec +2 -0
- data/lib/sumcli/templates/new/app/.ruby-version +1 -0
- data/lib/sumcli/templates/new/app/Dockerfile +14 -0
- data/lib/sumcli/templates/new/app/Gemfile +35 -0
- data/lib/sumcli/templates/new/app/Guardfile +33 -0
- data/lib/sumcli/templates/new/app/Procfile +5 -0
- data/lib/sumcli/templates/new/app/README.md +103 -0
- data/lib/sumcli/templates/new/app/Rakefile +38 -0
- data/lib/sumcli/templates/new/app/api/base.rb +6 -0
- data/lib/sumcli/templates/new/app/api/endpoints/base.rb +15 -0
- data/lib/sumcli/templates/new/app/app/exceptions/not_found_error.rb +1 -0
- data/lib/sumcli/templates/new/app/bin/console +13 -0
- data/lib/sumcli/templates/new/app/config/application.rb +15 -0
- data/lib/sumcli/templates/new/app/config/environment.rb +4 -0
- data/lib/sumcli/templates/new/app/config.ru +5 -0
- data/lib/sumcli/templates/new/app/docker-compose.yml +2 -0
- data/lib/sumcli/templates/new/app/spec/spec_helper.rb +39 -0
- data/lib/sumcli/version.rb +3 -0
- data/lib/sumcli.rb +6 -0
- data/sumcli.gemspec +53 -0
- metadata +445 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module Sumcli
|
6
|
+
module Commands
|
7
|
+
class G < Thor
|
8
|
+
|
9
|
+
namespace :g
|
10
|
+
|
11
|
+
desc 'endpoint NAME METHOD ROUTE', 'Generate a new endpoint using METHOD verb and matching url ROUTE'
|
12
|
+
method_option :help, aliases: '-h', type: :boolean,
|
13
|
+
desc: 'Display usage information'
|
14
|
+
def endpoint(name, method = nil, route = nil)
|
15
|
+
if options[:help]
|
16
|
+
invoke :help, ['endpoint']
|
17
|
+
else
|
18
|
+
require_relative 'g/endpoint'
|
19
|
+
Sumcli::Commands::G::Endpoint.new(name, method, route, options).execute
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../command'
|
4
|
+
|
5
|
+
module Sumcli
|
6
|
+
module Commands
|
7
|
+
class New < Sumcli::Command
|
8
|
+
def initialize(name, options)
|
9
|
+
@name = name
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(input: $stdin, output: $stdout)
|
14
|
+
output.puts "OK"
|
15
|
+
|
16
|
+
unless @name.nil? or File.directory?(@name)
|
17
|
+
directory = File.expand_path('../../templates/new/app', __FILE__)
|
18
|
+
return generator.copy_directory(directory, @name)
|
19
|
+
end
|
20
|
+
|
21
|
+
output.puts "Directory #{@name} already exists."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe API::<%= name.capitalize %> do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
API::<%= name.capitalize %>
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'GET /api/<%= name.downcase %>' do
|
11
|
+
let(:expected_response) { <%= name.downcase %> }
|
12
|
+
|
13
|
+
it 'returns all <%= name.downcase %>' do
|
14
|
+
get '/api/v1/<%= name.downcase %>'
|
15
|
+
|
16
|
+
expect(last_response.status).to eq(200)
|
17
|
+
expect(last_response.body).to eq(expected_response)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1 @@
|
|
1
|
+
2.6.2
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM ruby:2.6.2
|
2
|
+
|
3
|
+
# Installing application dependencies
|
4
|
+
RUN apt-get update
|
5
|
+
RUN apt-get install nodejs -y
|
6
|
+
|
7
|
+
ENV APP_HOME /usr/src/app/
|
8
|
+
RUN mkdir $APP_HOME
|
9
|
+
WORKDIR $APP_HOME
|
10
|
+
|
11
|
+
COPY Gemfile* $APP_HOME
|
12
|
+
RUN bundle install
|
13
|
+
|
14
|
+
COPY . $APP_HOME
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# source 'https://maven.internal.sumup.com/content/repositories/gems/'
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
|
4
|
+
|
5
|
+
ruby '2.6.2'
|
6
|
+
|
7
|
+
gem 'rack', '~> 2.0'
|
8
|
+
gem 'grape', '~> 1.2'
|
9
|
+
gem 'grape-entity', '~> 0.7'
|
10
|
+
gem 'global', '~> 1.1.0'
|
11
|
+
gem 'require_all', '~> 1.3', '>= 1.3.3'
|
12
|
+
gem 'faraday', '~> 0.15.4'
|
13
|
+
|
14
|
+
group :development, :test do
|
15
|
+
gem 'pry-byebug'
|
16
|
+
end
|
17
|
+
|
18
|
+
group :development do
|
19
|
+
gem 'rake'
|
20
|
+
gem 'thin'
|
21
|
+
gem 'guard', require: false
|
22
|
+
gem 'guard-rack', require: false
|
23
|
+
gem 'guard-bundler', require: false
|
24
|
+
end
|
25
|
+
|
26
|
+
group :test do
|
27
|
+
gem 'rspec'
|
28
|
+
gem 'rack-test'
|
29
|
+
gem 'factory_girl'
|
30
|
+
gem 'shoulda-matchers'
|
31
|
+
gem 'database_cleaner'
|
32
|
+
gem 'simplecov', require: false
|
33
|
+
gem 'codecov', :require => false
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard 'rack', port: 3000 do
|
19
|
+
watch('Gemfile.lock')
|
20
|
+
watch(%r{^(config|lib|app|api)/.*})
|
21
|
+
end
|
22
|
+
|
23
|
+
guard :bundler do
|
24
|
+
require 'guard/bundler'
|
25
|
+
require 'guard/bundler/verify'
|
26
|
+
helper = Guard::Bundler::Verify.new
|
27
|
+
|
28
|
+
files = ['Gemfile']
|
29
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
30
|
+
|
31
|
+
# Assume files are symlinked from somewhere
|
32
|
+
files.each { |file| watch(helper.real_path(file)) }
|
33
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# Grape Bootstrap
|
2
|
+
|
3
|
+
## Introduction
|
4
|
+
|
5
|
+
Bootstrap Grape application for REST APIs. Refer to [Wiki](https://github.com/rasouza/API_boilerplate/wiki) to know more about how features are implemented
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
- Live Reload Development ([Guard](https://github.com/guard/guard))
|
10
|
+
- RabbitMQ ([Sneakers](http://sneakers.io/))
|
11
|
+
- Cron Jobs ([Sidekiq](https://sidekiq.org/))
|
12
|
+
- Audit Logs ([PaperTrail](https://github.com/paper-trail-gem/paper_trail))
|
13
|
+
- [Codecov.io](https://codecov.io/)
|
14
|
+
- [Sentry.io](https://sentry.io/)
|
15
|
+
|
16
|
+
## Dependencies
|
17
|
+
|
18
|
+
- Ruby 2.6.2
|
19
|
+
- PostgreSQL
|
20
|
+
- Redis 5
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
- Clone poject
|
25
|
+
|
26
|
+
- Run bundler:
|
27
|
+
|
28
|
+
```shell
|
29
|
+
$ bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
- Create database and run migrations:
|
33
|
+
|
34
|
+
```shell
|
35
|
+
$ bundle exec rake db:create db:migrate
|
36
|
+
```
|
37
|
+
|
38
|
+
- Run application:
|
39
|
+
|
40
|
+
```shell
|
41
|
+
$ rackup -p 3000
|
42
|
+
```
|
43
|
+
|
44
|
+
- For development:
|
45
|
+
```shell
|
46
|
+
$ bundle exec guard
|
47
|
+
```
|
48
|
+
|
49
|
+
## Docker
|
50
|
+
|
51
|
+
To run application on docker:
|
52
|
+
|
53
|
+
- Install Docker and Docker-Compose
|
54
|
+
- Clone the project
|
55
|
+
- Run these commands on project root:
|
56
|
+
|
57
|
+
```shell
|
58
|
+
$ docker-compose build
|
59
|
+
$ docker-compose up
|
60
|
+
|
61
|
+
# Open another terminal and run:
|
62
|
+
$ docker-compose run web bundle exec rake db:create db:migrate
|
63
|
+
```
|
64
|
+
|
65
|
+
## Console
|
66
|
+
|
67
|
+
To use console, run the following command:
|
68
|
+
|
69
|
+
```shell
|
70
|
+
$ bin/console
|
71
|
+
```
|
72
|
+
|
73
|
+
## Background Jobs
|
74
|
+
|
75
|
+
To run Cron Jobs:
|
76
|
+
```shell
|
77
|
+
$ bin/sidekiq
|
78
|
+
```
|
79
|
+
|
80
|
+
To run RabbitMQ Workers:
|
81
|
+
```shell
|
82
|
+
$ bin/sneakers
|
83
|
+
```
|
84
|
+
|
85
|
+
## Tests
|
86
|
+
|
87
|
+
To execute tests, run the following command:
|
88
|
+
|
89
|
+
```shell
|
90
|
+
$ bundle exec rspec
|
91
|
+
```
|
92
|
+
|
93
|
+
## Routes
|
94
|
+
|
95
|
+
To show the application routes, run the following command:
|
96
|
+
|
97
|
+
```shell
|
98
|
+
$ bundle exec rake routes
|
99
|
+
```
|
100
|
+
|
101
|
+
## License
|
102
|
+
|
103
|
+
The software is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
|
13
|
+
task :environment do
|
14
|
+
ENV['RACK_ENV'] ||= 'development'
|
15
|
+
require File.expand_path('../config/environment', __FILE__)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "API Routes"
|
19
|
+
task routes: :environment do
|
20
|
+
API::Base.routes.each do |api|
|
21
|
+
method = api.request_method.ljust(10)
|
22
|
+
path = api.path
|
23
|
+
puts " #{method} #{path}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# load "tasks/otr-activerecord.rake"
|
28
|
+
|
29
|
+
namespace :db do
|
30
|
+
task :environment do
|
31
|
+
require_relative 'config/environment'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
#Load tasks
|
37
|
+
Dir.glob('lib/tasks/*.rake').each { |task| load task }
|
38
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
class NotFoundError < StandardError; end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path('../../config/environment', __FILE__)
|
4
|
+
|
5
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
6
|
+
# with your gem easier. You can also use a different console, if you like.
|
7
|
+
|
8
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
9
|
+
# require "pry"
|
10
|
+
# Pry.start
|
11
|
+
|
12
|
+
require "irb"
|
13
|
+
IRB.start
|
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'api'))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'app'))
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require 'bundler/setup'
|
6
|
+
|
7
|
+
Bundler.require :default, ENV['RACK_ENV']
|
8
|
+
|
9
|
+
Global.configure do |config|
|
10
|
+
config.environment = ENV['RACK_ENV']
|
11
|
+
config.config_directory = File.dirname(__FILE__)
|
12
|
+
end
|
13
|
+
|
14
|
+
require_rel '../app'
|
15
|
+
require_rel '../api'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'codecov'
|
5
|
+
SimpleCov.start
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
7
|
+
require File.expand_path('../../config/environment', __FILE__)
|
8
|
+
require 'rspec'
|
9
|
+
require 'shoulda-matchers'
|
10
|
+
require 'factory_girl'
|
11
|
+
require 'database_cleaner'
|
12
|
+
|
13
|
+
Shoulda::Matchers.configure do |config|
|
14
|
+
config.integrate do |with|
|
15
|
+
with.library :active_record
|
16
|
+
with.test_framework :rspec
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
#Shoulda-Matchers
|
22
|
+
config.include(Shoulda::Matchers::ActiveModel, type: :model)
|
23
|
+
config.include(Shoulda::Matchers::ActiveRecord, type: :model)
|
24
|
+
|
25
|
+
#Factory Girl
|
26
|
+
config.include(FactoryGirl::Syntax::Methods)
|
27
|
+
config.before(:suite) do
|
28
|
+
FactoryGirl.find_definitions
|
29
|
+
DatabaseCleaner.strategy = :transaction
|
30
|
+
DatabaseCleaner.clean_with(:truncation)
|
31
|
+
end
|
32
|
+
|
33
|
+
config.around(:each) do |example|
|
34
|
+
DatabaseCleaner.cleaning do
|
35
|
+
example.run
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
data/lib/sumcli.rb
ADDED
data/sumcli.gemspec
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "sumcli/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sumcli"
|
8
|
+
spec.license = "MIT"
|
9
|
+
spec.version = Sumcli::VERSION
|
10
|
+
spec.authors = ["Rodrigo Alves"]
|
11
|
+
spec.email = ["rodrigo.souza@sumup.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Scaffolds SumUp microservices code.}
|
14
|
+
spec.description = %q{Scaffolds SumUp microservices code.}
|
15
|
+
spec.homepage = "https://rubygems.org/gems/sumcli"
|
16
|
+
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_dependency "tty-box", "~> 0.3.0"
|
28
|
+
spec.add_dependency "tty-color", "~> 0.4"
|
29
|
+
spec.add_dependency "tty-command", "~> 0.8.0"
|
30
|
+
spec.add_dependency "tty-config", "~> 0.3.0"
|
31
|
+
spec.add_dependency "tty-cursor", "~> 0.6"
|
32
|
+
spec.add_dependency "tty-editor", "~> 0.5.0"
|
33
|
+
spec.add_dependency "tty-file", "~> 0.7.0"
|
34
|
+
spec.add_dependency "tty-font", "~> 0.2.0"
|
35
|
+
spec.add_dependency "tty-markdown", "~> 0.5.0"
|
36
|
+
spec.add_dependency "tty-pager", "~> 0.12.0"
|
37
|
+
spec.add_dependency "tty-pie", "~> 0.1.0"
|
38
|
+
spec.add_dependency "tty-platform", "~> 0.2.0"
|
39
|
+
spec.add_dependency "tty-progressbar", "~> 0.16.0"
|
40
|
+
spec.add_dependency "tty-prompt", "~> 0.18.0"
|
41
|
+
spec.add_dependency "tty-screen", "~> 0.6"
|
42
|
+
spec.add_dependency "tty-spinner", "~> 0.9.0"
|
43
|
+
spec.add_dependency "tty-table", "~> 0.10.0"
|
44
|
+
spec.add_dependency "tty-tree", "~> 0.2.0"
|
45
|
+
spec.add_dependency "tty-which", "~> 0.4"
|
46
|
+
spec.add_dependency "pastel", "~> 0.7.2"
|
47
|
+
spec.add_dependency "thor", "~> 0.20.0"
|
48
|
+
spec.add_dependency 'activesupport', '~> 5.0'
|
49
|
+
|
50
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
51
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
52
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
53
|
+
end
|