potassium 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 +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +8 -0
- data/circle.yml +1 -1
- data/lib/potassium/assets/.dockerignore +3 -0
- data/lib/potassium/assets/{.env.example.erb → .env.development.erb} +0 -2
- data/lib/potassium/assets/Dockerfile.ci +5 -3
- data/lib/potassium/assets/bin/cibuild.erb +87 -22
- data/lib/potassium/assets/circle.yml +4 -2
- data/lib/potassium/assets/docker-compose.ci.yml +3 -0
- data/lib/potassium/helpers/gem-helpers.rb +1 -0
- data/lib/potassium/recipes/ci.rb +4 -0
- data/lib/potassium/recipes/database.rb +15 -8
- data/lib/potassium/recipes/devise.rb +1 -2
- data/lib/potassium/recipes/env.rb +11 -2
- data/lib/potassium/recipes/git.rb +0 -4
- data/lib/potassium/recipes/github.rb +2 -2
- data/lib/potassium/recipes/heroku.rb +0 -6
- data/lib/potassium/recipes/paperclip.rb +2 -2
- data/lib/potassium/recipes/pundit.rb +14 -14
- data/lib/potassium/recipes/ruby.rb +2 -6
- data/lib/potassium/recipes/style.rb +1 -1
- data/lib/potassium/version.rb +2 -1
- data/spec/features/new_project_spec.rb +14 -0
- data/spec/support/fake_heroku.rb +1 -3
- data/spec/support/potassium_test_helpers.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e744bb4e04fa650c7190cfb645c050d0ff83691f
|
4
|
+
data.tar.gz: 588d03c4d1385f5d74387ab7720b32d45e3d2df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49627be487d9b2e423cc51cac06d135ca89b6c1e5e74d1facfd9a504d804ea4956fd6261fb91b1d2b27d9d03e428cadff4a8fc1fc2867d93411082ba730391b6
|
7
|
+
data.tar.gz: a723bb7e25ab5849b0b19cce675afd27a7083a1564937ed413189756166620dc77763c5cad3f1ea6827ae1065e19fc5ba04605f610797a3a8c7dfb6ae2e94cf0
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 2.1.0
|
6
|
+
|
7
|
+
- Fix discard_gem helper
|
8
|
+
- Adds install command for database recipe
|
9
|
+
- Remove check for heroku pipelines plugins, [#88]
|
10
|
+
- Use postgresql by default, [#83]
|
11
|
+
- Update ruby to `2.3.1` [#89]
|
12
|
+
|
5
13
|
## 2.0.0
|
6
14
|
|
7
15
|
Features:
|
data/circle.yml
CHANGED
@@ -1,27 +1,92 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
|
+
trap "exit" SIGINT SIGTERM
|
2
3
|
|
3
|
-
|
4
|
+
command -v docker >/dev/null 2>&1 && docker info >/dev/null || {
|
5
|
+
printf >&2 "\e[31mI require docker but it's not installed. Aborting.\e[0m\n"; exit 1;
|
6
|
+
}
|
7
|
+
|
8
|
+
DOCKER_COMPOSE_ARGS="-f docker-compose.ci.yml"
|
9
|
+
|
10
|
+
# Build Image
|
11
|
+
build(){
|
12
|
+
docker-compose $DOCKER_COMPOSE_ARGS build test
|
13
|
+
}
|
14
|
+
|
15
|
+
# Wait services to be ready
|
16
|
+
wait_services(){
|
17
|
+
function test_service {
|
18
|
+
docker-compose $DOCKER_COMPOSE_ARGS run test sh -c "nc -z $1 $2"
|
19
|
+
}
|
20
|
+
|
21
|
+
count=0
|
22
|
+
# Chain tests together by using &&
|
23
|
+
until (
|
24
|
+
<% if(selected?(:database, :mysql) || selected?(:database, :postgresql))-%>
|
25
|
+
test_service '$<%=get(:database).to_s.upcase%>_HOST' '$<%=get(:database).to_s.upcase%>_PORT' && \
|
26
|
+
<% end-%>
|
27
|
+
echo "Services ready"
|
28
|
+
)
|
29
|
+
do
|
30
|
+
((count++))
|
31
|
+
if [ $count -gt 50 ]
|
32
|
+
then
|
33
|
+
echo "Services didn't become ready in time"
|
34
|
+
exit 1
|
35
|
+
else
|
36
|
+
echo "Waiting for services to become ready..."
|
37
|
+
fi
|
38
|
+
sleep 0.5
|
39
|
+
done
|
40
|
+
}
|
41
|
+
|
42
|
+
# Prepare dependencies
|
43
|
+
dependencies(){
|
44
|
+
docker-compose $DOCKER_COMPOSE_ARGS run test bundle install
|
45
|
+
}
|
46
|
+
|
47
|
+
# Prepare database
|
48
|
+
database(){
|
49
|
+
docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rake db:create db:schema:load
|
50
|
+
}
|
51
|
+
|
52
|
+
# Run the specs
|
53
|
+
tests(){
|
54
|
+
[ -n "$CI" ] && {
|
55
|
+
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter --format RspecJunitFormatter -o $HOME/.rspec_reports/junit.xml"
|
56
|
+
RSPEC_FORMAT_ARGS="--format progress --no-color"
|
57
|
+
}
|
58
|
+
docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
59
|
+
}
|
4
60
|
|
5
|
-
|
6
|
-
|
7
|
-
|
61
|
+
# Run the complete ci build
|
62
|
+
no_ci(){
|
63
|
+
build
|
64
|
+
wait_services
|
65
|
+
dependencies
|
66
|
+
database
|
67
|
+
tests
|
8
68
|
}
|
9
69
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
70
|
+
case "$1" in
|
71
|
+
"")
|
72
|
+
no_ci
|
73
|
+
;;
|
74
|
+
"services")
|
75
|
+
wait_services
|
76
|
+
;;
|
77
|
+
"deps"|"dependencies")
|
78
|
+
dependencies
|
79
|
+
;;
|
80
|
+
"db"|"database")
|
81
|
+
database
|
82
|
+
;;
|
83
|
+
"specs"|"tests")
|
84
|
+
tests
|
85
|
+
;;
|
86
|
+
"build")
|
87
|
+
build
|
88
|
+
;;
|
89
|
+
*)
|
90
|
+
echo "Usage: cibuild [services|deps|db|specs|build]"
|
91
|
+
;;
|
92
|
+
esac
|
@@ -6,11 +6,13 @@ dependencies:
|
|
6
6
|
override:
|
7
7
|
- docker-compose -f docker-compose.ci.yml pull
|
8
8
|
- docker-compose -f docker-compose.ci.yml build test
|
9
|
+
- bin/cibuild services
|
10
|
+
- bin/cibuild deps
|
9
11
|
|
10
12
|
database:
|
11
13
|
override:
|
12
|
-
-
|
14
|
+
- bin/cibuild db
|
13
15
|
|
14
16
|
test:
|
15
17
|
override:
|
16
|
-
- bin/cibuild
|
18
|
+
- bin/cibuild tests
|
data/lib/potassium/recipes/ci.rb
CHANGED
@@ -9,6 +9,10 @@ class Recipes::Ci < Rails::AppBuilder
|
|
9
9
|
|
10
10
|
copy_file '../assets/docker-compose.ci.yml', 'docker-compose.ci.yml'
|
11
11
|
|
12
|
+
gather_gems(:test) do
|
13
|
+
gather_gem 'rspec_junit_formatter', '0.2.2'
|
14
|
+
end
|
15
|
+
|
12
16
|
compose = DockerHelpers.new('docker-compose.ci.yml')
|
13
17
|
|
14
18
|
if selected?(:database, :mysql)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class Recipes::Database < Rails::AppBuilder
|
2
2
|
def ask
|
3
3
|
databases = {
|
4
|
-
mysql: "MySQL",
|
5
4
|
postgresql: "PostgreSQL",
|
5
|
+
mysql: "MySQL",
|
6
6
|
none: "None, thanks"
|
7
7
|
}
|
8
8
|
|
@@ -14,24 +14,31 @@ class Recipes::Database < Rails::AppBuilder
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create
|
17
|
-
|
18
|
-
mysql: { name: 'mysql', gem_name: 'mysql2', version: '~> 0.3.18', relational: true },
|
19
|
-
postgresql: { name: 'postgresql', gem_name: 'pg', relational: true }
|
20
|
-
}
|
21
|
-
|
22
|
-
if db = databases[get(:database)]
|
17
|
+
if db = databases(get(:database))
|
23
18
|
if db[:relational]
|
24
19
|
activate_for_active_record(db)
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
28
23
|
|
24
|
+
def install
|
25
|
+
ask
|
26
|
+
create
|
27
|
+
end
|
28
|
+
|
29
29
|
private
|
30
30
|
|
31
|
+
def databases(database)
|
32
|
+
databases = {
|
33
|
+
postgresql: { name: 'postgresql', gem_name: 'pg', relational: true },
|
34
|
+
mysql: { name: 'mysql', gem_name: 'mysql2', version: '~> 0.3.18', relational: true }
|
35
|
+
}
|
36
|
+
databases[database]
|
37
|
+
end
|
38
|
+
|
31
39
|
def activate_for_active_record(db)
|
32
40
|
remove_file 'config/database.yml'
|
33
41
|
template "../assets/config/database_#{db[:name]}.yml.erb", 'config/database.yml'
|
34
|
-
|
35
42
|
discard_gem 'sqlite3'
|
36
43
|
if db[:version]
|
37
44
|
gather_gem db[:gem_name], db[:version]
|
@@ -56,8 +56,7 @@ class Recipes::Devise < Rails::AppBuilder
|
|
56
56
|
"# config.pepper = 'onhcylrat7x8bjyr5o15sxaix3vbu0sl'"
|
57
57
|
end
|
58
58
|
|
59
|
-
append_to_file '.env.
|
60
|
-
append_to_file '.env', 'DEVISE_SECRET_KEY='
|
59
|
+
append_to_file '.env.development', 'DEVISE_SECRET_KEY='
|
61
60
|
add_readme_section :internal_dependencies, :devise
|
62
61
|
end
|
63
62
|
end
|
@@ -4,7 +4,16 @@ class Recipes::Env < Rails::AppBuilder
|
|
4
4
|
gather_gem('dotenv-rails')
|
5
5
|
end
|
6
6
|
|
7
|
-
template '../assets/.env.
|
8
|
-
|
7
|
+
template '../assets/.env.development.erb', '.env.development'
|
8
|
+
append_to_file '.gitignore', ".env.local\n"
|
9
|
+
append_to_file '.gitignore', ".env\n"
|
10
|
+
|
11
|
+
env_config =
|
12
|
+
<<-RUBY.gsub(/^ {7}/, '')
|
13
|
+
config.before_configuration do
|
14
|
+
Dotenv.load(Dotenv::Railtie.root.join('.env.development'))
|
15
|
+
end
|
16
|
+
RUBY
|
17
|
+
application env_config.strip, env: 'test'
|
9
18
|
end
|
10
19
|
end
|
@@ -2,10 +2,6 @@ class Recipes::Git < Rails::AppBuilder
|
|
2
2
|
def create
|
3
3
|
git :init
|
4
4
|
after(:database_creation) do
|
5
|
-
append_to_file '.gitignore', ".env\n"
|
6
|
-
append_to_file '.gitignore', ".powder\n"
|
7
|
-
append_to_file '.gitignore', "vendor/assets/bower_components\n"
|
8
|
-
|
9
5
|
git add: "."
|
10
6
|
git commit: %{ -m 'Initial commit' }
|
11
7
|
end
|
@@ -10,12 +10,12 @@ class Recipes::Github < Rails::AppBuilder
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
set(:github_repo_name, repo_name)
|
13
|
-
set(:
|
13
|
+
set(:github_repo, github_repo_create)
|
14
14
|
set(:github_repo_private, github_repo_private)
|
15
15
|
end
|
16
16
|
|
17
17
|
def create
|
18
|
-
github_repo_create(get(:github_repo_name), get(:github_repo_private))
|
18
|
+
github_repo_create(get(:github_repo_name), get(:github_repo_private)) if selected?(:github_repo)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -107,12 +107,6 @@ class Recipes::Heroku < Rails::AppBuilder
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def add_app_to_pipeline(app_env_name, environment)
|
110
|
-
pipelines_plugin = `heroku plugins | grep pipelines`
|
111
|
-
if pipelines_plugin.empty?
|
112
|
-
puts "You need heroku pipelines plugin. Run: heroku plugins:install heroku-pipelines"
|
113
|
-
exit 1
|
114
|
-
end
|
115
|
-
|
116
110
|
pipeline = `heroku pipelines:info \
|
117
111
|
#{heroku_pipeline_name} 2>/dev/null | grep #{heroku_pipeline_name}`
|
118
112
|
pipeline_command = pipeline.empty? ? "create" : "add"
|
@@ -30,8 +30,8 @@ class Recipes::Paperclip < Rails::AppBuilder
|
|
30
30
|
}
|
31
31
|
RUBY
|
32
32
|
application paperclip_config.strip, env: 'production'
|
33
|
-
append_to_file '.env.
|
34
|
-
append_to_file '.
|
33
|
+
append_to_file '.env.development', 'AWS_BUCKET='
|
34
|
+
append_to_file '.gitignore', "/public/system/*\n"
|
35
35
|
add_readme_section :internal_dependencies, :paperclip
|
36
36
|
end
|
37
37
|
end
|
@@ -30,6 +30,20 @@ class Recipes::Pundit < Rails::AppBuilder
|
|
30
30
|
gem_exists?(/pundit/)
|
31
31
|
end
|
32
32
|
|
33
|
+
def install_admin_pundit
|
34
|
+
initializer = "config/initializers/active_admin.rb"
|
35
|
+
gsub_file initializer, /# config\.authorization_adapter =[^\n]+\n/ do
|
36
|
+
"config.authorization_adapter = ActiveAdmin::PunditAdapter\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
template "../assets/active_admin/pundit_page_policy.rb",
|
40
|
+
"app/policies/active_admin/page_policy.rb"
|
41
|
+
template "../assets/active_admin/comment_policy.rb",
|
42
|
+
"app/policies/active_admin/comment_policy.rb"
|
43
|
+
template "../assets/active_admin/admin_user_policy.rb",
|
44
|
+
"app/policies/admin_user_policy.rb"
|
45
|
+
end
|
46
|
+
|
33
47
|
private
|
34
48
|
|
35
49
|
def run_pundit_installer
|
@@ -44,18 +58,4 @@ class Recipes::Pundit < Rails::AppBuilder
|
|
44
58
|
add_readme_section :internal_dependencies, :pundit
|
45
59
|
end
|
46
60
|
end
|
47
|
-
|
48
|
-
def install_admin_pundit
|
49
|
-
initializer = "config/initializers/active_admin.rb"
|
50
|
-
gsub_file initializer, /# config\.authorization_adapter =[^\n]+\n/ do
|
51
|
-
"config.authorization_adapter = ActiveAdmin::PunditAdapter\n"
|
52
|
-
end
|
53
|
-
|
54
|
-
template "../assets/active_admin/pundit_page_policy.rb",
|
55
|
-
"app/policies/active_admin/page_policy.rb"
|
56
|
-
template "../assets/active_admin/comment_policy.rb",
|
57
|
-
"app/policies/active_admin/comment_policy.rb"
|
58
|
-
template "../assets/active_admin/admin_user_policy.rb",
|
59
|
-
"app/policies/admin_user_policy.rb"
|
60
|
-
end
|
61
61
|
end
|
@@ -3,21 +3,17 @@ require 'semantic'
|
|
3
3
|
|
4
4
|
class Recipes::Ruby < Rails::AppBuilder
|
5
5
|
def create
|
6
|
-
info 'Getting platanus latest ruby version...'
|
7
6
|
info "Using ruby version #{version_alias}"
|
8
7
|
create_file '.ruby-version', version_alias
|
9
8
|
end
|
10
9
|
|
11
10
|
private
|
12
11
|
|
13
|
-
def
|
14
|
-
|
15
|
-
rescue
|
16
|
-
RUBY_VERSION
|
12
|
+
def version
|
13
|
+
Potassium::RUBY_VERSION
|
17
14
|
end
|
18
15
|
|
19
16
|
def version_alias
|
20
|
-
version = latest
|
21
17
|
Semantic::Version.new(version).instance_eval { "#{major}.#{minor}" }
|
22
18
|
end
|
23
19
|
end
|
@@ -3,7 +3,7 @@ class Recipes::Style < Rails::AppBuilder
|
|
3
3
|
copy_file '../assets/.rubocop.yml', '.rubocop.yml'
|
4
4
|
copy_file '../assets/.ruby_style.yml', '.ruby_style.yml'
|
5
5
|
copy_file '../assets/.hound.yml', '.hound.yml'
|
6
|
-
append_to_file '.gitignore',
|
6
|
+
append_to_file '.gitignore', ".rubocop-http*\n"
|
7
7
|
add_readme_header :style_guide
|
8
8
|
end
|
9
9
|
|
data/lib/potassium/version.rb
CHANGED
@@ -35,4 +35,18 @@ RSpec.describe "A new project" do
|
|
35
35
|
|
36
36
|
expect(hound_config_file).to include("config_file: .ruby_style.yml")
|
37
37
|
end
|
38
|
+
|
39
|
+
it "configures postgresql" do
|
40
|
+
database_config_file = IO.read("#{project_path}/config/database.yml")
|
41
|
+
gemfile = IO.read("#{project_path}/Gemfile")
|
42
|
+
|
43
|
+
expect(database_config_file).to include(%{adapter: postgresql})
|
44
|
+
expect(gemfile).to include %{gem 'pg'}
|
45
|
+
end
|
46
|
+
|
47
|
+
it "configures the correct ruby version" do
|
48
|
+
ruby_version_file = IO.read("#{project_path}/.ruby-version")
|
49
|
+
|
50
|
+
expect(ruby_version_file).to eq("2.3")
|
51
|
+
end
|
38
52
|
end
|
data/spec/support/fake_heroku.rb
CHANGED
@@ -8,9 +8,7 @@ class FakeHeroku
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run!
|
11
|
-
if @args.first == "
|
12
|
-
puts "heroku-pipelines@0.29.0"
|
13
|
-
elsif @args.first == "pipelines:info"
|
11
|
+
if @args.first == "pipelines:info"
|
14
12
|
if FakeHeroku.has_created_pipeline?
|
15
13
|
puts "=== dummy-app\nstaging:\tpl-dummy-app-staging\nproduction:\tpl-dummy-app-production"
|
16
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: potassium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juliogarciag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- ".hound.yml"
|
178
178
|
- ".rspec"
|
179
179
|
- ".rubocop.yml"
|
180
|
+
- ".ruby-version"
|
180
181
|
- ".ruby_style.yml"
|
181
182
|
- CHANGELOG.md
|
182
183
|
- Gemfile
|
@@ -190,8 +191,9 @@ files:
|
|
190
191
|
- lib/potassium.rb
|
191
192
|
- lib/potassium/assets/.bowerrc
|
192
193
|
- lib/potassium/assets/.buildpacks
|
194
|
+
- lib/potassium/assets/.dockerignore
|
193
195
|
- lib/potassium/assets/.editorconfig
|
194
|
-
- lib/potassium/assets/.env.
|
196
|
+
- lib/potassium/assets/.env.development.erb
|
195
197
|
- lib/potassium/assets/.hound.yml
|
196
198
|
- lib/potassium/assets/.pryrc
|
197
199
|
- lib/potassium/assets/.rubocop.yml
|