forked from octree-gva/decidim-module-geo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
119 lines (109 loc) · 2.98 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# frozen_string_literal: true
require "decidim/dev/common_rake"
def install_module(path)
Dir.chdir(path) do
system("bundle exec rake decidim_geo:install:migrations")
end
end
def seed_db(path)
Dir.chdir(path) do
system("bundle exec rake db:seed")
end
end
##
# Tasks for test_app
##
desc "Prepare for testing"
task :prepare_tests do
# Remove previous existing db, and recreate one.
Dir.chdir("development_app") do
system("bundle exec rake db:drop")
system("bundle exec rake db:create")
end
ENV["RAILS_ENV"] = "test"
database_yml = {
"test" => {
"adapter" => "postgis",
"encoding" => "unicode",
"host" => ENV.fetch("DATABASE_HOST", "localhost"),
"port" => ENV.fetch("DATABASE_PORT", "5432").to_i,
"username" => ENV.fetch("DATABASE_USERNAME", "decidim"),
"password" => ENV.fetch("DATABASE_PASSWORD", "insecure-password"),
"database" => "#{base_app_name}_test"
}
}
config_file = File.expand_path("spec/decidim_dummy_app/config/database.yml", __dir__)
File.open(config_file, "w") { |f| YAML.dump(database_yml, f) }
Dir.chdir("spec/decidim_dummy_app") do
system("bundle exec rails db:migrate")
end
end
desc "Generates a decidim_dummy_app app for testing"
task :test_app do
Bundler.with_original_env do
generate_decidim_app(
"spec/decidim_dummy_app",
"--app_name",
base_app_name.to_s,
"--path",
"../..",
"--skip_spring",
"--demo",
"--force_ssl",
"false",
"--locales",
"en,fr,es"
)
end
install_module("spec/decidim_dummy_app")
Rake::Task["prepare_tests"].invoke
end
##
# Tasks for developement_app
##
desc "Prepare for development"
task :prepare_dev do
# Remove previous existing db, and recreate one.
Dir.chdir("development_app") do
system("bundle exec rake db:drop")
system("bundle exec rake db:create")
end
ENV["RAILS_ENV"] = "development"
database_yml = {
"development" => {
"adapter" => "postgis",
"encoding" => "unicode",
"host" => ENV.fetch("DATABASE_HOST", "localhost"),
"port" => ENV.fetch("DATABASE_PORT", "5432").to_i,
"username" => ENV.fetch("DATABASE_USERNAME", "decidim"),
"password" => ENV.fetch("DATABASE_PASSWORD", "insecure-password"),
"database" => "#{base_app_name}_development"
}
}
config_file = File.expand_path("development_app/config/database.yml", __dir__)
File.open(config_file, "w") { |f| YAML.dump(database_yml, f) }
Dir.chdir("development_app") do
system("bundle exec rake db:migrate")
system("npm install -D webpack-dev-server")
end
end
desc "Generates a development app"
task :development_app do
Bundler.with_original_env do
generate_decidim_app(
"development_app",
"--app_name",
base_app_name.to_s,
"recreate_db",
"--path",
"..",
"--skip_spring",
"--demo",
"--force_ssl",
"false",
"--demo"
)
end
install_module("development_app")
Rake::Task["prepare_dev"].invoke
end