potassium 5.2.2 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +103 -28
- data/.circleci/setup-rubygems.sh +3 -0
- data/.gitignore +2 -1
- data/.node-version +1 -0
- data/.rubocop.yml +530 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +92 -1
- data/README.md +51 -45
- data/docs/DSL.md +5 -5
- data/lib/potassium/assets/.circleci/config.yml.erb +151 -0
- data/lib/potassium/assets/.eslintrc.json +352 -0
- data/lib/potassium/assets/.github/pull_request_template.md +9 -0
- data/lib/potassium/assets/.rubocop.yml +528 -0
- data/lib/potassium/assets/.stylelintrc.json +46 -0
- data/lib/potassium/assets/Makefile.erb +21 -32
- data/lib/potassium/assets/README.yml +59 -15
- data/lib/potassium/assets/active_admin/admin-component.vue +35 -0
- data/lib/potassium/assets/active_admin/admin_application.js +14 -0
- data/lib/potassium/assets/active_admin/init_activeadmin_vue.rb +10 -0
- data/lib/potassium/assets/app/graphql/graphql_controller.rb +55 -0
- data/lib/potassium/assets/app/graphql/mutations/login_mutation.rb +23 -0
- data/lib/potassium/assets/app/graphql/queries/base_query.rb +4 -0
- data/lib/potassium/assets/app/graphql/types/base/base_argument.rb +4 -0
- data/lib/potassium/assets/app/graphql/types/base/base_enum.rb +4 -0
- data/lib/potassium/assets/app/graphql/types/base/base_field.rb +5 -0
- data/lib/potassium/assets/app/graphql/types/base/base_input_object.rb +5 -0
- data/lib/potassium/assets/app/graphql/types/base/base_interface.rb +7 -0
- data/lib/potassium/assets/app/graphql/types/base/base_object.rb +5 -0
- data/lib/potassium/assets/app/graphql/types/base/base_scalar.rb +4 -0
- data/lib/potassium/assets/app/graphql/types/base/base_union.rb +4 -0
- data/lib/potassium/assets/app/graphql/types/mutation_type.rb +10 -0
- data/lib/potassium/assets/app/graphql/types/query_type.rb +13 -0
- data/lib/potassium/assets/app/javascript/app.spec.js +14 -0
- data/lib/potassium/assets/app/uploaders/base_uploader.rb +11 -0
- data/lib/potassium/assets/app/uploaders/image_uploader.rb +5 -0
- data/lib/potassium/assets/app/views/shared/_gtm_body.html.erb +4 -0
- data/lib/potassium/assets/app/views/shared/_gtm_head.html.erb +7 -0
- data/lib/potassium/assets/bin/release +1 -1
- data/lib/potassium/assets/bin/setup.erb +1 -1
- data/lib/potassium/assets/config/database_mysql.yml.erb +2 -2
- data/lib/potassium/assets/config/database_postgresql.yml.erb +2 -2
- data/lib/potassium/assets/config/graphql_playground.rb +20 -0
- data/lib/potassium/assets/config/puma.rb +1 -1
- data/lib/potassium/assets/config/shrine.rb +36 -0
- data/lib/potassium/assets/lib/tasks/auto_annotate_models.rake +2 -1
- data/lib/potassium/assets/package.json +4 -1
- data/lib/potassium/assets/redis.yml +1 -2
- data/lib/potassium/assets/testing/rails_helper.rb +2 -0
- data/lib/potassium/cli/commands/create.rb +12 -19
- data/lib/potassium/cli_options.rb +77 -26
- data/lib/potassium/helpers/gem-helpers.rb +1 -1
- data/lib/potassium/helpers/template-helpers.rb +8 -0
- data/lib/potassium/newest_version_ensurer.rb +19 -36
- data/lib/potassium/node_version_ensurer.rb +30 -0
- data/lib/potassium/recipes/admin.rb +3 -3
- data/lib/potassium/recipes/annotate.rb +1 -1
- data/lib/potassium/recipes/api.rb +93 -21
- data/lib/potassium/recipes/background_processor.rb +66 -19
- data/lib/potassium/recipes/ci.rb +10 -38
- data/lib/potassium/recipes/data_migrate.rb +44 -0
- data/lib/potassium/recipes/database.rb +4 -0
- data/lib/potassium/recipes/database_container.rb +7 -5
- data/lib/potassium/recipes/draper.rb +1 -10
- data/lib/potassium/recipes/file_storage.rb +66 -0
- data/lib/potassium/recipes/front_end.rb +225 -9
- data/lib/potassium/recipes/github.rb +93 -15
- data/lib/potassium/recipes/google_tag_manager.rb +90 -0
- data/lib/potassium/recipes/heroku.rb +42 -29
- data/lib/potassium/recipes/mailer.rb +18 -2
- data/lib/potassium/recipes/monitoring.rb +5 -0
- data/lib/potassium/recipes/node.rb +21 -0
- data/lib/potassium/recipes/rack_cors.rb +18 -15
- data/lib/potassium/recipes/schedule.rb +17 -2
- data/lib/potassium/recipes/style.rb +21 -3
- data/lib/potassium/recipes/vue_admin.rb +124 -0
- data/lib/potassium/templates/application.rb +10 -7
- data/lib/potassium/version.rb +7 -4
- data/potassium.gemspec +11 -6
- data/spec/features/api_spec.rb +25 -0
- data/spec/features/background_processor_spec.rb +19 -6
- data/spec/features/ci_spec.rb +7 -4
- data/spec/features/data_migrate_spec.rb +14 -0
- data/spec/features/database_container_spec.rb +1 -5
- data/spec/features/draper_spec.rb +1 -6
- data/spec/features/file_storage_spec.rb +75 -0
- data/spec/features/front_end_spec.rb +102 -0
- data/spec/features/github_spec.rb +53 -8
- data/spec/features/google_tag_manager_spec.rb +59 -0
- data/spec/features/graphql_spec.rb +71 -0
- data/spec/features/heroku_spec.rb +1 -1
- data/spec/features/mailer_spec.rb +16 -0
- data/spec/features/new_project_spec.rb +6 -14
- data/spec/features/node_spec.rb +28 -0
- data/spec/features/power_types_spec.rb +5 -16
- data/spec/features/schedule_spec.rb +11 -4
- data/spec/features/vue_admin_spec.rb +47 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/fake_octokit.rb +31 -0
- data/spec/support/potassium_test_helpers.rb +26 -9
- data/tmp/.keep +0 -0
- metadata +152 -46
- data/lib/potassium/assets/.circleci/config.yml +0 -20
- data/lib/potassium/assets/Dockerfile.ci +0 -6
- data/lib/potassium/assets/active_admin/active_admin.js.coffee +0 -4
- data/lib/potassium/assets/active_admin/init_activeadmin_angular.rb +0 -8
- data/lib/potassium/assets/api/api_error_concern.rb +0 -32
- data/lib/potassium/assets/api/base_controller.rb +0 -9
- data/lib/potassium/assets/api/draper_responder.rb +0 -62
- data/lib/potassium/assets/api/responder.rb +0 -41
- data/lib/potassium/assets/aws.rb +0 -1
- data/lib/potassium/assets/bin/cibuild.erb +0 -100
- data/lib/potassium/assets/docker-compose.ci.yml +0 -11
- data/lib/potassium/assets/sidekiq_scheduler.yml +0 -9
- data/lib/potassium/assets/testing/paperclip.rb +0 -59
- data/lib/potassium/recipes/active_storage.rb +0 -40
- data/lib/potassium/recipes/angular_admin.rb +0 -56
- data/lib/potassium/recipes/aws_sdk.rb +0 -7
- data/lib/potassium/recipes/paperclip.rb +0 -47
- data/spec/features/active_storage_spec.rb +0 -30
- data/spec/features/front_end.rb +0 -30
@@ -1,4 +1,5 @@
|
|
1
1
|
set :app_name, app_name
|
2
|
+
set :node_version, node_version
|
2
3
|
set :titleized_app_name, get(:app_name).titleize
|
3
4
|
set :underscorized_app_name, get(:app_name).underscore
|
4
5
|
set :dasherized_app_name, get(:app_name).dasherize
|
@@ -19,8 +20,9 @@ run_action(:asking) do
|
|
19
20
|
ask :database
|
20
21
|
ask :devise
|
21
22
|
ask :admin
|
23
|
+
ask :google_tag_manager
|
22
24
|
ask :front_end
|
23
|
-
ask :
|
25
|
+
ask :vue_admin
|
24
26
|
ask :mailer
|
25
27
|
ask :background_processor
|
26
28
|
ask :schedule
|
@@ -29,8 +31,7 @@ run_action(:asking) do
|
|
29
31
|
ask :i18n
|
30
32
|
ask :api
|
31
33
|
ask :draper
|
32
|
-
ask :
|
33
|
-
ask :paperclip
|
34
|
+
ask :file_storage
|
34
35
|
ask :heroku
|
35
36
|
ask :github
|
36
37
|
end
|
@@ -46,20 +47,22 @@ run_action(:recipe_loading) do
|
|
46
47
|
create :database_container
|
47
48
|
create :database
|
48
49
|
create :annotate
|
50
|
+
create :data_migrate
|
49
51
|
create :listen
|
52
|
+
create :node
|
50
53
|
create :ruby
|
51
54
|
create :yarn
|
52
55
|
create :editorconfig
|
53
|
-
create :aws_sdk
|
54
56
|
create :mailer
|
55
57
|
create :background_processor
|
56
58
|
create :schedule
|
57
59
|
create :i18n
|
58
60
|
create :pry
|
59
61
|
create :better_errors
|
62
|
+
create :monitoring
|
60
63
|
create :devise
|
61
64
|
create :admin
|
62
|
-
create :
|
65
|
+
create :vue_admin
|
63
66
|
create :seeds
|
64
67
|
create :error_reporting
|
65
68
|
create :pundit
|
@@ -69,13 +72,13 @@ run_action(:recipe_loading) do
|
|
69
72
|
create :draper
|
70
73
|
create :power_types
|
71
74
|
create :rack_cors
|
72
|
-
create :
|
73
|
-
create :paperclip
|
75
|
+
create :file_storage
|
74
76
|
create :tzinfo
|
75
77
|
create :script
|
76
78
|
create :github
|
77
79
|
create :cleanup
|
78
80
|
create :front_end
|
81
|
+
create :google_tag_manager
|
79
82
|
end
|
80
83
|
|
81
84
|
info "Gathered enough information. Applying the template. Wait a minute."
|
data/lib/potassium/version.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module Potassium
|
2
|
-
VERSION = "
|
3
|
-
RUBY_VERSION = "2.
|
4
|
-
RAILS_VERSION = "~>
|
5
|
-
RUBOCOP_VERSION = "~>
|
2
|
+
VERSION = "6.3.0"
|
3
|
+
RUBY_VERSION = "2.7.0"
|
4
|
+
RAILS_VERSION = "~> 6.0.2"
|
5
|
+
RUBOCOP_VERSION = "~> 1.9"
|
6
|
+
RUBOCOP_RSPEC_VERSION = "~> 2.2"
|
6
7
|
POSTGRES_VERSION = "11.3"
|
7
8
|
MYSQL_VERSION = "5.7"
|
9
|
+
NODE_VERSION = "12"
|
10
|
+
TAILWINDCSS = "npm:@tailwindcss/postcss7-compat"
|
8
11
|
end
|
data/potassium.gemspec
CHANGED
@@ -18,15 +18,20 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~>
|
22
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec", "~> 3.4.0"
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
24
22
|
spec.add_development_dependency "pry", "~> 0.10.3"
|
23
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
25
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
25
26
|
spec.add_development_dependency "rubocop", Potassium::RUBOCOP_VERSION
|
26
|
-
spec.
|
27
|
+
spec.add_development_dependency "rubocop-performance"
|
28
|
+
spec.add_development_dependency "rubocop-rails"
|
29
|
+
spec.add_development_dependency "rubocop-rspec", Potassium::RUBOCOP_RSPEC_VERSION
|
30
|
+
spec.add_runtime_dependency "gems", "~> 0.8"
|
27
31
|
spec.add_runtime_dependency "gli", "~> 2.12.2"
|
28
32
|
spec.add_runtime_dependency "inquirer", "~> 0.2"
|
29
|
-
spec.add_runtime_dependency "gems", "~> 0.8"
|
30
|
-
spec.add_runtime_dependency "semantic", "~> 1.4"
|
31
33
|
spec.add_runtime_dependency "levenshtein", "~> 0.2"
|
34
|
+
spec.add_runtime_dependency "octokit", "~> 4.18"
|
35
|
+
spec.add_runtime_dependency "rails", Potassium::RAILS_VERSION
|
36
|
+
spec.add_runtime_dependency "semantic", "~> 1.4"
|
32
37
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Api" do
|
4
|
+
before :all do
|
5
|
+
drop_dummy_database
|
6
|
+
remove_project_directory
|
7
|
+
create_dummy_project("api" => :rest)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "adds power_api related gems to Gemfile" do
|
11
|
+
gemfile_content = IO.read("#{project_path}/Gemfile")
|
12
|
+
expect(gemfile_content).to include("gem 'power_api'")
|
13
|
+
expect(gemfile_content).to include("gem 'rswag-specs'")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "adds the power_api brief to README file" do
|
17
|
+
readme = IO.read("#{project_path}/README.md")
|
18
|
+
expect(readme).to include("Power API")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "installs power_api" do
|
22
|
+
content = IO.read("#{project_path}/app/controllers/api/base_controller.rb")
|
23
|
+
expect(content).to include("Api::BaseController < PowerApi::BaseController")
|
24
|
+
end
|
25
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
RSpec.describe "BackgroundProcessor" do
|
4
|
-
context "working with sidekiq" do
|
5
|
+
context "when working with sidekiq and no mailer" do
|
5
6
|
before :all do
|
6
7
|
drop_dummy_database
|
7
8
|
remove_project_directory
|
8
|
-
create_dummy_project("background_processor" =>
|
9
|
+
create_dummy_project("background_processor" => true, "heroku" => true)
|
9
10
|
end
|
10
11
|
|
11
12
|
it "adds sidekiq gem to Gemfile" do
|
@@ -41,6 +42,9 @@ RSpec.describe "BackgroundProcessor" do
|
|
41
42
|
it "adds ENV vars" do
|
42
43
|
content = IO.read("#{project_path}/.env.development")
|
43
44
|
expect(content).to include("DB_POOL=25")
|
45
|
+
expect(content).to include('REDIS_HOST=127.0.0.1')
|
46
|
+
expect(content).to include('REDIS_PORT=$(make services-port SERVICE=redis PORT=6379)')
|
47
|
+
expect(content).to include('REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}/1')
|
44
48
|
end
|
45
49
|
|
46
50
|
it "adds sidekiq.rb file" do
|
@@ -48,19 +52,28 @@ RSpec.describe "BackgroundProcessor" do
|
|
48
52
|
expect(content).to include("require 'sidekiq'")
|
49
53
|
end
|
50
54
|
|
51
|
-
it "adds sidekiq.yml file" do
|
52
|
-
|
53
|
-
|
55
|
+
it "adds sidekiq.yml file with no mailer queue" do
|
56
|
+
yml_path = "#{project_path}/config/sidekiq.yml"
|
57
|
+
content = IO.read(yml_path)
|
58
|
+
expect(File.exist?(yml_path)).to be true
|
59
|
+
expect(content).not_to include("- mailers")
|
54
60
|
end
|
55
61
|
|
56
62
|
it "adds redis.yml file" do
|
57
63
|
content = IO.read("#{project_path}/config/redis.yml")
|
58
|
-
expect(content).to include("
|
64
|
+
expect(content).to include("REDIS_URL")
|
59
65
|
end
|
60
66
|
|
61
67
|
it "mounts sidekiq app" do
|
62
68
|
content = IO.read("#{project_path}/config/routes.rb")
|
63
69
|
expect(content).to include("mount Sidekiq::Web => '/queue'")
|
64
70
|
end
|
71
|
+
|
72
|
+
it 'adds redis to docker-compose' do
|
73
|
+
compose_file = IO.read("#{project_path}/docker-compose.yml")
|
74
|
+
compose_content = YAML.safe_load(compose_file, symbolize_names: true)
|
75
|
+
|
76
|
+
expect(compose_content[:services]).to include(:redis)
|
77
|
+
end
|
65
78
|
end
|
66
79
|
end
|
data/spec/features/ci_spec.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "rubocop"
|
3
3
|
|
4
|
-
RSpec.describe
|
4
|
+
RSpec.describe 'CI' do
|
5
5
|
before(:all) do
|
6
6
|
drop_dummy_database
|
7
7
|
remove_project_directory
|
8
|
-
create_dummy_project
|
8
|
+
create_dummy_project
|
9
9
|
end
|
10
10
|
|
11
|
-
it "correctly
|
12
|
-
|
11
|
+
it "correctly bundles the config file" do
|
12
|
+
yml_path = "#{project_path}/.circleci/config.yml"
|
13
|
+
content = IO.read(yml_path)
|
14
|
+
expect(File.exist?(yml_path)).to be true
|
15
|
+
expect(content).to include('circleci/ruby', 'cache', 'rspec', 'reviewdog')
|
13
16
|
end
|
14
17
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe 'DataMigrate' do
|
4
|
+
let(:gemfile) { IO.read("#{project_path}/Gemfile") }
|
5
|
+
let(:annotate_task) { IO.read("#{project_path}/lib/tasks/auto_annotate_models.rake") }
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
remove_project_directory
|
9
|
+
create_dummy_project
|
10
|
+
end
|
11
|
+
|
12
|
+
it { expect(gemfile).to include("data_migrate") }
|
13
|
+
it { expect(annotate_task).to include("data_migrate_tasks") }
|
14
|
+
end
|
@@ -11,10 +11,6 @@ RSpec.describe "DatabaseContainer" do
|
|
11
11
|
create_dummy_project("database" => database)
|
12
12
|
end
|
13
13
|
|
14
|
-
after do
|
15
|
-
`docker-compose -f #{project_path}/docker-compose.yml down`
|
16
|
-
end
|
17
|
-
|
18
14
|
[:postgresql, :mysql].each do |db_type|
|
19
15
|
context "when database is #{db_type}" do
|
20
16
|
let!(:database) { db_type }
|
@@ -32,7 +28,7 @@ RSpec.describe "DatabaseContainer" do
|
|
32
28
|
.to include("DB_PORT=$(make services-port SERVICE=#{service_name} PORT=#{db_port})")
|
33
29
|
expect(env_file).to include("DB_HOST=127.0.0.1")
|
34
30
|
expect(File.exist?("#{project_path}/Makefile")).to be true
|
35
|
-
expect(setup_file).to include("
|
31
|
+
expect(setup_file).to include("docker-compose up -d")
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
@@ -4,7 +4,7 @@ RSpec.describe "Draper" do
|
|
4
4
|
before :all do
|
5
5
|
drop_dummy_database
|
6
6
|
remove_project_directory
|
7
|
-
create_dummy_project("draper" => true
|
7
|
+
create_dummy_project("draper" => true)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "adds the Draper gem to Gemfile" do
|
@@ -17,11 +17,6 @@ RSpec.describe "Draper" do
|
|
17
17
|
expect(readme).to include("Draper")
|
18
18
|
end
|
19
19
|
|
20
|
-
it "adds api responder to work with draper" do
|
21
|
-
responder_content = IO.read("#{project_path}/app/responders/api_responder.rb")
|
22
|
-
expect(responder_content).to include("decorated_resource")
|
23
|
-
end
|
24
|
-
|
25
20
|
it "adds decorators directory" do
|
26
21
|
content = IO.read("#{project_path}/app/decorators/.keep")
|
27
22
|
expect(content).to be_empty
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "File Storage" do
|
4
|
+
context "when selecting active_storage" do
|
5
|
+
before :all do
|
6
|
+
drop_dummy_database
|
7
|
+
remove_project_directory
|
8
|
+
create_dummy_project(storage: :active_storage)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "adds the aws-sdk-s3 gem to Gemfile" do
|
12
|
+
gemfile_content = IO.read("#{project_path}/Gemfile")
|
13
|
+
expect(gemfile_content).to include("gem 'aws-sdk-s3'")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "customizes config file" do
|
17
|
+
content = IO.read("#{project_path}/config/storage.yml")
|
18
|
+
expect(content).to include("bucket: <%= ENV['S3_BUCKET'] %>")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "adds brief to README file" do
|
22
|
+
content = IO.read("#{project_path}/README.md")
|
23
|
+
expect(content).to include("Active Storage")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "uses amazon on production env" do
|
27
|
+
content = IO.read("#{project_path}/config/environments/production.rb")
|
28
|
+
expect(content).to include("config.active_storage.service = :amazon")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "adds S3 bucket ENV vars" do
|
32
|
+
content = IO.read("#{project_path}/.env.development")
|
33
|
+
expect(content).to include("S3_BUCKET=")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when selecting shrine" do
|
38
|
+
before :all do
|
39
|
+
drop_dummy_database
|
40
|
+
remove_project_directory
|
41
|
+
create_dummy_project(storage: :shrine)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "adds the aws-sdk-s3, shrine and marcel gems to Gemfile" do
|
45
|
+
gemfile_content = IO.read("#{project_path}/Gemfile")
|
46
|
+
expect(gemfile_content).to include("gem 'aws-sdk-s3'")
|
47
|
+
expect(gemfile_content).to include("gem 'shrine'")
|
48
|
+
expect(gemfile_content).to include("gem 'marcel'")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "adds brief to README file" do
|
52
|
+
content = IO.read("#{project_path}/README.md")
|
53
|
+
expect(content).to include("Shrine")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "adds shrine initializer" do
|
57
|
+
expect(File.exist?("#{project_path}/config/initializers/shrine.rb")).to be true
|
58
|
+
end
|
59
|
+
|
60
|
+
it "adds base_uploader and image_uploader" do
|
61
|
+
expect(File.exist?("#{project_path}/app/uploaders/base_uploader.rb")).to be true
|
62
|
+
expect(File.exist?("#{project_path}/app/uploaders/image_uploader.rb")).to be true
|
63
|
+
end
|
64
|
+
|
65
|
+
it "adds S3 bucket ENV vars" do
|
66
|
+
content = IO.read("#{project_path}/.env.development")
|
67
|
+
expect(content).to include("S3_BUCKET=")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "adds filestorage path to gitignore" do
|
71
|
+
content = IO.read("#{project_path}/.gitignore")
|
72
|
+
expect(content).to include("/public/uploads")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Front end" do
|
4
|
+
before :all do
|
5
|
+
drop_dummy_database
|
6
|
+
remove_project_directory
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:application_css_path) { "#{project_path}/app/javascript/css/application.css" }
|
10
|
+
let(:gemfile) { IO.read("#{project_path}/Gemfile") }
|
11
|
+
let(:node_modules_file) { IO.read("#{project_path}/package.json") }
|
12
|
+
let(:application_js_file) { IO.read("#{project_path}/app/javascript/packs/application.js") }
|
13
|
+
let(:layout_file) { IO.read("#{project_path}/app/views/layouts/application.html.erb") }
|
14
|
+
let(:application_css_file) { IO.read(application_css_path) }
|
15
|
+
let(:tailwind_config_file) { IO.read("#{project_path}/tailwind.config.js") }
|
16
|
+
let(:rails_css_file) { IO.read("#{project_path}/app/assets/stylesheets/application.css") }
|
17
|
+
|
18
|
+
it "creates a project without a front end framework" do
|
19
|
+
remove_project_directory
|
20
|
+
create_dummy_project("front_end" => "None")
|
21
|
+
expect(gemfile).to include('webpacker')
|
22
|
+
expect(File).not_to exist(application_css_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def expect_to_have_tailwind_compatibility_build
|
26
|
+
expect(node_modules_file).to include("\"tailwindcss\": \"npm:@tailwindcss/postcss7-compat\"")
|
27
|
+
expect(node_modules_file).to include("\"autoprefixer\": \"^9\"")
|
28
|
+
expect(node_modules_file).to include("\"postcss\": \"^7\"")
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with vue" do
|
32
|
+
before(:all) do
|
33
|
+
remove_project_directory
|
34
|
+
create_dummy_project("front_end" => "vue")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "creates a project with vue in compiler mode as frontend framework" do
|
38
|
+
expect(gemfile).to include('webpacker')
|
39
|
+
expect(node_modules_file).to include("\"vue\"")
|
40
|
+
expect(application_js_file).to include('vue/dist/vue.esm')
|
41
|
+
expect(application_js_file).to include("el: '#vue-app'")
|
42
|
+
expect(layout_file).to include('id="vue-app"')
|
43
|
+
end
|
44
|
+
|
45
|
+
it "creates a project with only one js pack tag" do
|
46
|
+
expect(layout_file.scan("javascript_pack_tag").length).to eq(1)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "creates a vue project with client css" do
|
50
|
+
expect(application_js_file).to include("import '../css/application.css';")
|
51
|
+
expect(layout_file).to include("<%= stylesheet_pack_tag 'application' %>")
|
52
|
+
expect(rails_css_file).not_to include('*= require_tree', '*= require_self')
|
53
|
+
end
|
54
|
+
|
55
|
+
it "creates a vue project with tailwindcss" do
|
56
|
+
expect(node_modules_file).to include("\"tailwindcss\"")
|
57
|
+
expect(application_css_file).to include(
|
58
|
+
"@import 'tailwindcss/base';",
|
59
|
+
"@import 'tailwindcss/components';"
|
60
|
+
)
|
61
|
+
expect(tailwind_config_file).to include('module.exports')
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
|
65
|
+
expect_to_have_tailwind_compatibility_build
|
66
|
+
end
|
67
|
+
|
68
|
+
context "with graphql" do
|
69
|
+
before(:all) do
|
70
|
+
remove_project_directory
|
71
|
+
create_dummy_project("front_end" => "vue", "api" => "graphql")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "creates a vue project with apollo" do
|
75
|
+
expect(node_modules_file).to include("\"vue-apollo\"")
|
76
|
+
expect(application_js_file).to include("import { ApolloClient } from 'apollo-client';")
|
77
|
+
expect(application_js_file).to include("Vue.use(VueApollo)")
|
78
|
+
expect(application_js_file).to include("apolloProvider,")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with angular" do
|
84
|
+
before(:all) do
|
85
|
+
remove_project_directory
|
86
|
+
create_dummy_project("front_end" => "angular")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "creates a project without vue as front end framework" do
|
90
|
+
expect(gemfile).to include('webpacker')
|
91
|
+
expect(node_modules_file).to include("\"@angular/core\"")
|
92
|
+
end
|
93
|
+
|
94
|
+
it "creates application_js_file for tailwind without vue" do
|
95
|
+
expect(application_js_file).to include("import '../css/application.css';")
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'includes correct packages for tailwind, postcss and autoprefixer compatibility build' do
|
99
|
+
expect_to_have_tailwind_compatibility_build
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|