decidim-generators 0.27.4 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -5
  3. data/Gemfile.lock +372 -407
  4. data/README.md +2 -2
  5. data/lib/decidim/generators/app_generator.rb +83 -24
  6. data/lib/decidim/generators/app_templates/.node-version +1 -0
  7. data/lib/decidim/generators/app_templates/.rubocop.yml +2 -0
  8. data/lib/decidim/generators/app_templates/.ruby-version +1 -0
  9. data/lib/decidim/generators/app_templates/README.md.erb +7 -12
  10. data/lib/decidim/generators/app_templates/another_dummy_authorization_handler.rb +1 -1
  11. data/lib/decidim/generators/app_templates/budgets_workflow_random.rb +1 -1
  12. data/lib/decidim/generators/app_templates/bullet_initializer.rb +1 -1
  13. data/lib/decidim/generators/app_templates/config/boot.rb.tt +16 -0
  14. data/lib/decidim/generators/app_templates/database.yml.erb +1 -1
  15. data/lib/decidim/generators/app_templates/decidim_application.scss +2 -1
  16. data/lib/decidim/generators/app_templates/dummy_authorization_handler.rb +5 -5
  17. data/lib/decidim/generators/app_templates/initializer.rb +19 -8
  18. data/lib/decidim/generators/app_templates/rack_profiler_initializer.rb +2 -1
  19. data/lib/decidim/generators/app_templates/secrets.yml.erb +14 -8
  20. data/lib/decidim/generators/component_generator.rb +44 -2
  21. data/lib/decidim/generators/component_templates/.eslintrc.json +3 -0
  22. data/lib/decidim/generators/component_templates/.node-version +1 -0
  23. data/lib/decidim/generators/component_templates/.rubocop.yml +2 -0
  24. data/lib/decidim/generators/component_templates/.ruby-version +1 -0
  25. data/lib/decidim/generators/component_templates/.stylelintrc.json +3 -0
  26. data/lib/decidim/generators/component_templates/README.md.erb +7 -1
  27. data/lib/decidim/generators/component_templates/app/controllers/decidim/component/admin/application_controller.rb.erb +11 -0
  28. data/lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb +23 -0
  29. data/lib/decidim/generators/component_templates/decidim-component.gemspec.erb +9 -2
  30. data/lib/decidim/generators/component_templates/github/ci.yml.erb +77 -0
  31. data/lib/decidim/generators/component_templates/gitignore +5 -0
  32. data/lib/decidim/generators/component_templates/lib/decidim/component/test/factories.rb.erb +1 -0
  33. data/lib/decidim/generators/component_templates/package.json.erb +21 -0
  34. data/lib/decidim/generators/component_templates/spec/lib/version_spec.rb.erb +13 -0
  35. data/lib/decidim/generators/component_templates/spec/permissions/admin/permissions_spec.rb.erb +40 -0
  36. data/lib/decidim/generators/install_generator.rb +12 -7
  37. data/lib/decidim/generators/test/generator_examples.rb +72 -40
  38. data/lib/decidim/generators/version.rb +1 -1
  39. metadata +29 -13
  40. data/lib/decidim/generators/app_templates/_decidim-settings.scss +0 -7
  41. data/lib/decidim/generators/app_templates/social_share_button.rb +0 -8
  42. data/lib/decidim/generators/component_templates/circleci/config.yml +0 -47
data/README.md CHANGED
@@ -28,14 +28,14 @@ require in your final decidim application in order to use it. To do that, you
28
28
  need to include the plugin in your application's `Gemfile`.
29
29
 
30
30
  For example, if you generated your component at
31
- `~/decidim-module-experimental_component`, you'll need to edit your `Gemfile` like
31
+ `~/decidim-module-experimental_component`, you will need to edit your `Gemfile` like
32
32
  this in order for the component to be used:
33
33
 
34
34
  ```ruby
35
35
  gem "decidim-experimental_plugin", path: "~/decidim-module-experimental_plugin"
36
36
  ```
37
37
 
38
- Once you do that, and boot your application, you'll see the new component being
38
+ Once you do that, and boot your application, you will see the new component being
39
39
  offered in the "New component" selector on the "Components" section of any
40
40
  participatory space in the admin dashboard.
41
41
 
@@ -55,11 +55,11 @@ module Decidim
55
55
 
56
56
  class_option :skip_bundle, type: :boolean,
57
57
  default: true, # this is to avoid installing gems in this step yet (done by InstallGenerator)
58
- desc: "Don't run bundle install"
58
+ desc: "Do not run bundle install"
59
59
 
60
60
  class_option :skip_gemfile, type: :boolean,
61
61
  default: false,
62
- desc: "Don't generate a Gemfile for the application"
62
+ desc: "Do not generate a Gemfile for the application"
63
63
 
64
64
  class_option :demo, type: :boolean,
65
65
  default: false,
@@ -71,7 +71,7 @@ module Decidim
71
71
 
72
72
  class_option :force_ssl, type: :string,
73
73
  default: "true",
74
- desc: "Doesn't force to use ssl"
74
+ desc: "Does not force to use ssl"
75
75
 
76
76
  class_option :locales, type: :string,
77
77
  default: "",
@@ -87,11 +87,16 @@ module Decidim
87
87
 
88
88
  class_option :skip_webpack_install, type: :boolean,
89
89
  default: true,
90
- desc: "Don't run Webpack install"
90
+ desc: "Do not run Webpack install"
91
91
 
92
92
  class_option :dev_ssl, type: :boolean,
93
93
  default: false,
94
- desc: "Don't add Puma development SSL configuration options"
94
+ desc: "Do not add Puma development SSL configuration options"
95
+
96
+ # we disable the webpacker installation as we will use shakapacker
97
+ def webpacker_gemfile_entry
98
+ []
99
+ end
95
100
 
96
101
  def database_yml
97
102
  template "database.yml.erb", "config/database.yml", force: true
@@ -122,11 +127,26 @@ module Decidim
122
127
  template "LICENSE-AGPLv3.txt", "LICENSE-AGPLv3.txt"
123
128
  end
124
129
 
130
+ def rubocop
131
+ copy_file ".rubocop.yml", ".rubocop.yml"
132
+ end
133
+
134
+ def ruby_version
135
+ copy_file ".ruby-version", ".ruby-version", force: true
136
+ end
137
+
138
+ def node_version
139
+ copy_file ".node-version", ".node-version"
140
+ end
141
+
125
142
  def gemfile
126
143
  return if options[:skip_gemfile]
127
144
 
128
145
  if branch.present?
129
146
  get target_gemfile, "Gemfile", force: true
147
+ append_file "Gemfile", %(\ngem "net-imap", "~> 0.2.3", group: :development)
148
+ append_file "Gemfile", %(\ngem "net-pop", "~> 0.1.1", group: :development)
149
+ append_file "Gemfile", %(\ngem "net-smtp", "~> 0.3.1", group: :development)
130
150
  get "#{target_gemfile}.lock", "Gemfile.lock", force: true
131
151
  else
132
152
  copy_file target_gemfile, "Gemfile", force: true
@@ -139,7 +159,7 @@ module Decidim
139
159
 
140
160
  gsub_file "Gemfile", /gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}"
141
161
 
142
- %w(conferences consultations elections initiatives templates).each do |component|
162
+ %w(conferences design elections initiatives templates).each do |component|
143
163
  if options[:demo]
144
164
  gsub_file "Gemfile", /gem "decidim-#{component}".*/, "gem \"decidim-#{component}\", #{gem_modifier}"
145
165
  else
@@ -203,28 +223,22 @@ module Decidim
203
223
  end
204
224
  end
205
225
 
206
- def tweak_bootsnap
207
- gsub_file "config/boot.rb", %r{require 'bootsnap/setup'.*$}, <<~RUBY.rstrip
208
- require "bootsnap"
209
-
210
- env = ENV["RAILS_ENV"] || "development"
211
-
212
- Bootsnap.setup(
213
- cache_dir: File.expand_path(File.join("..", "tmp", "cache"), __dir__),
214
- development_mode: env == "development",
215
- load_path_cache: true,
216
- compile_cache_iseq: !ENV["SIMPLECOV"],
217
- compile_cache_yaml: true
218
- )
219
- RUBY
220
- end
221
-
222
226
  def tweak_spring
223
227
  return unless File.exist?("config/spring.rb")
224
228
 
225
229
  prepend_to_file "config/spring.rb", "require \"decidim/spring\"\n\n"
226
230
  end
227
231
 
232
+ def tweak_csp_initializer
233
+ return unless File.exist?("config/initializers/content_security_policy.rb")
234
+
235
+ remove_file("config/initializers/content_security_policy.rb")
236
+ create_file "config/initializers/content_security_policy.rb" do
237
+ %(# For tuning the Content Security Policy, check the Decidim documentation site
238
+ # https://docs.decidim.org/develop/en/customize/content_security_policy)
239
+ end
240
+ end
241
+
228
242
  def puma_ssl_options
229
243
  return unless options[:dev_ssl]
230
244
 
@@ -243,8 +257,29 @@ module Decidim
243
257
  CONFIG
244
258
  end
245
259
 
246
- def add_ignore_uploads
247
- append_file ".gitignore", "\n# Ignore public uploads\npublic/uploads" unless options["skip_git"]
260
+ def modify_gitignore
261
+ return if options[:skip_git]
262
+
263
+ append_file ".gitignore", <<~GITIGNORE
264
+
265
+ # Ignore env configuration files
266
+ .env
267
+ .envrc
268
+ .rbenv-vars
269
+
270
+ # Ignore the files and folders generated through Webpack
271
+ /public/decidim-packs
272
+ /public/packs-test
273
+ /public/sw.js
274
+ /public/sw.js.map
275
+
276
+ # Ignore node modules
277
+ /node_modules
278
+ GITIGNORE
279
+ end
280
+
281
+ def add_ignore_tailwind_configuration
282
+ append_file ".gitignore", "\n\n# Ignore Tailwind configuration\ntailwind.config.js" unless options["skip_git"]
248
283
  end
249
284
 
250
285
  def remove_default_error_pages
@@ -252,6 +287,10 @@ module Decidim
252
287
  remove_file "public/500.html"
253
288
  end
254
289
 
290
+ def remove_default_favicon
291
+ remove_file "public/favicon.ico"
292
+ end
293
+
255
294
  def decidim_initializer
256
295
  copy_file "initializer.rb", "config/initializers/decidim.rb"
257
296
 
@@ -278,6 +317,26 @@ module Decidim
278
317
  "# config.available_locales = Rails.application.secrets.decidim[:available_locales].presence || [:en]"
279
318
  end
280
319
 
320
+ def dev_performance_config
321
+ gsub_file "config/environments/development.rb", /^end\n$/, <<~CONFIG
322
+
323
+ # Performance configs for local testing
324
+ if ENV.fetch("RAILS_BOOST_PERFORMANCE", false).to_s == "true"
325
+ # Indicate boost performance mode
326
+ config.boost_performance = true
327
+ # Enable caching and eager load
328
+ config.eager_load = true
329
+ config.cache_classes = true
330
+ # Logging
331
+ config.log_level = :info
332
+ config.action_view.logger = nil
333
+ # Compress the HTML responses with gzip
334
+ config.middleware.use Rack::Deflater
335
+ end
336
+ end
337
+ CONFIG
338
+ end
339
+
281
340
  def authorization_handler
282
341
  return unless options[:demo]
283
342
 
@@ -0,0 +1,2 @@
1
+ inherit_gem:
2
+ decidim-dev: rubocop-decidim.yml
@@ -6,17 +6,12 @@ This is the open-source repository for <%= app_name %>, based on [Decidim](https
6
6
 
7
7
  ## Setting up the application
8
8
 
9
- You will need to do some steps before having the app working properly once you've deployed it:
9
+ You will need to do some steps before having the app working properly once you have deployed it:
10
10
 
11
- 1. Open a Rails console in the server: `bundle exec rails console`
12
- 2. Create a System Admin user:
13
- ```ruby
14
- user = Decidim::System::Admin.new(email: <email>, password: <password>, password_confirmation: <password>)
15
- user.save!
16
- ```
17
- 3. Visit `<your app url>/system` and login with your system admin credentials
18
- 4. Create a new organization. Check the locales you want to use for that organization, and select a default locale.
19
- 5. Set the correct default host for the organization, otherwise the app will not work properly. Note that you need to include any subdomain you might be using.
20
- 6. Fill the rest of the form and submit it.
11
+ 1. Create a System Admin user: `bin/rails decidim_system:create_admin`
12
+ 1. Visit `<your app url>/system` and login with your system admin credentials
13
+ 1. Create a new organization. Check the locales you want to use for that organization, and select a default locale.
14
+ 1. Set the correct default host for the organization, otherwise the app will not work properly. Note that you need to include any subdomain you might be using.
15
+ 1. Fill the rest of the form and submit it.
21
16
 
22
- You're good to go!
17
+ You are good to go!
@@ -9,7 +9,7 @@ class AnotherDummyAuthorizationHandler < Decidim::AuthorizationHandler
9
9
  validate :valid_passport_number
10
10
 
11
11
  def metadata
12
- super.merge(passport_number: passport_number, postal_code: postal_code)
12
+ super.merge(passport_number:, postal_code:)
13
13
  end
14
14
 
15
15
  def unique_id
@@ -5,7 +5,7 @@
5
5
  # Note: random selection should be deterministic for the same user and the same budgets component.
6
6
  # As the budget resources list could change and affect the random selection, it also allows to finish orders created on other budgets.
7
7
  class BudgetsWorkflowRandom < Decidim::Budgets::Workflows::Base
8
- # Highlight the resource if the user didn't vote and is allowed to vote on it.
8
+ # Highlight the resource if the user did not vote and is allowed to vote on it.
9
9
  def highlighted?(resource)
10
10
  vote_allowed?(resource)
11
11
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if defined?(Bullet)
3
+ if defined?(Bullet) && !Rails.application.config.try(:boost_performance)
4
4
  Rails.application.config.after_initialize do
5
5
  Bullet.enable = true
6
6
  Bullet.bullet_logger = true
@@ -0,0 +1,16 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ <% if depend_on_bootsnap? -%>
5
+ require "bootsnap"
6
+
7
+ env = ENV["RAILS_ENV"] || "development"
8
+
9
+ Bootsnap.setup(
10
+ cache_dir: File.expand_path(File.join("..", "tmp", "cache"), __dir__),
11
+ development_mode: env == "development",
12
+ load_path_cache: true,
13
+ compile_cache_iseq: !ENV["SIMPLECOV"],
14
+ compile_cache_yaml: true
15
+ )
16
+ <%- end -%>
@@ -41,7 +41,7 @@ development:
41
41
  #password:
42
42
 
43
43
  # Connect on a TCP socket. Omitted by default since the client uses a
44
- # domain socket that doesn't need configuration. Windows does not have
44
+ # domain socket that does not need configuration. Windows does not have
45
45
  # domain sockets, so uncomment these lines.
46
46
  #host: localhost
47
47
 
@@ -2,6 +2,7 @@
2
2
  // Notice that this file is included at the very end of the stylesheets packs to have
3
3
  // more priority
4
4
  //
5
- // To override CSS variables or Foundation settings use _decidim-settings.scss
5
+ // To override the Tailwind CSS configuration you can do so by following the instructions
6
+ // available at https://docs.decidim.org/en/develop/customize/styles.html#_tailwind_css
6
7
  //
7
8
  // By default this is empty.
@@ -43,7 +43,7 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
43
43
  # be created or not, you should return a Boolean value.
44
44
  #
45
45
  # Note that if you set some validations and overwrite this method, then the
46
- # validations will not run, so it's easier to remove this method and rewrite
46
+ # validations will not run, so it is easier to remove this method and rewrite
47
47
  # your logic using ActiveModel validations.
48
48
  #
49
49
  # def valid?
@@ -66,10 +66,10 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
66
66
  # can do it here.
67
67
  #
68
68
  # You must return a Hash that will be serialized to the authorization when
69
- # it's created, and available though authorization.metadata
69
+ # it is created, and available though authorization.metadata
70
70
  #
71
71
  def metadata
72
- super.merge(document_number: document_number, postal_code: postal_code, scope_id: scope_id)
72
+ super.merge(document_number:, postal_code:, scope_id:)
73
73
  end
74
74
 
75
75
  private
@@ -105,7 +105,7 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
105
105
  if disallowed_user_postal_code
106
106
  if user_postal_code
107
107
  i18n_postal_codes_key = "extra_explanation.user_postal_codes"
108
- user_postal_code_params = { user_postal_code: user_postal_code }
108
+ user_postal_code_params = { user_postal_code: }
109
109
  else
110
110
  i18n_postal_codes_key = "extra_explanation.postal_codes"
111
111
  user_postal_code_params = {}
@@ -126,7 +126,7 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
126
126
  if disallowed_user_user_scope
127
127
  if user_scope_id
128
128
  i18n_scope_key = "extra_explanation.user_scope"
129
- user_scope_params = { user_scope_name: user_scope_name }
129
+ user_scope_params = { user_scope_name: }
130
130
  else
131
131
  i18n_scope_key = "extra_explanation.scope"
132
132
  user_scope_params = {}
@@ -40,8 +40,16 @@ Decidim.configure do |config|
40
40
  # Enable the service worker. By default is disabled in development and enabled in the rest of environments
41
41
  config.service_worker_enabled = Rails.application.secrets.decidim[:service_worker_enabled].present?
42
42
 
43
+ # Sets the list of static pages' slugs that can include content blocks.
44
+ # By default is only enabled in the terms-of-service static page to allow a summary to be added and include
45
+ # sections with a two-pane view
46
+ config.page_blocks = Rails.application.secrets.decidim[:page_blocks].presence || %w(terms-of-service)
47
+
43
48
  # Map and Geocoder configuration
44
49
  #
50
+ # See Decidim docs at https://docs.decidim.org/en/develop/services/maps.html
51
+ # for more information about how it works and how to set it up.
52
+ #
45
53
  # == HERE Maps ==
46
54
  # config.maps = {
47
55
  # provider: :here,
@@ -333,6 +341,9 @@ Decidim.configure do |config|
333
341
  #
334
342
  # config.machine_translation_service = "MyTranslationService"
335
343
 
344
+ # Defines the social networking services used for social sharing
345
+ config.social_share_services = Rails.application.secrets.decidim[:social_share_services]
346
+
336
347
  # Defines the name of the cookie used to check if the user allows Decidim to
337
348
  # set cookies.
338
349
  config.consent_cookie_name = Rails.application.secrets.decidim[:consent_cookie_name] if Rails.application.secrets.decidim[:consent_cookie_name].present?
@@ -367,6 +378,10 @@ Decidim.configure do |config|
367
378
  # }
368
379
  # ]
369
380
 
381
+ # Defines additional content security policies following the structure
382
+ # Read more: https://docs.decidim.org/en/develop/configure/initializer#_content_security_policy
383
+ config.content_security_policies_extra = {}
384
+
370
385
  # Admin admin password configurations
371
386
  Rails.application.secrets.dig(:decidim, :admin_password, :strong).tap do |strong_pw|
372
387
  # When the strong password is not configured, default to true
@@ -385,7 +400,8 @@ Decidim.configure do |config|
385
400
  end
386
401
  config.follow_http_x_forwarded_host = Rails.application.secrets.decidim[:follow_http_x_forwarded_host].present?
387
402
  config.maximum_conversation_message_length = Rails.application.secrets.decidim[:maximum_conversation_message_length].to_i
388
- config.password_blacklist = Rails.application.secrets.decidim[:password_blacklist] if Rails.application.secrets.decidim[:password_blacklist].present?
403
+ config.password_similarity_length = Rails.application.secrets.decidim[:password_similarity_length] if Rails.application.secrets.decidim[:password_similarity_length].present?
404
+ config.denied_passwords = Rails.application.secrets.decidim[:denied_passwords] if Rails.application.secrets.decidim[:denied_passwords].present?
389
405
  config.allow_open_redirects = Rails.application.secrets.decidim[:allow_open_redirects] if Rails.application.secrets.decidim[:allow_open_redirects].present?
390
406
  end
391
407
 
@@ -434,12 +450,6 @@ if Decidim.module_installed? :accountability
434
450
  end
435
451
  end
436
452
 
437
- if Decidim.module_installed? :consultations
438
- Decidim::Consultations.configure do |config|
439
- config.stats_cache_expiration_time = Rails.application.secrets.dig(:decidim, :consultations, :stats_cache_expiration_time).to_i.minutes
440
- end
441
- end
442
-
443
453
  if Decidim.module_installed? :initiatives
444
454
  Decidim::Initiatives.configure do |config|
445
455
  unless Rails.application.secrets.dig(:decidim, :initiatives, :creation_enabled) == "auto"
@@ -463,9 +473,10 @@ end
463
473
 
464
474
  if Decidim.module_installed? :elections
465
475
  Decidim::Elections.configure do |config|
466
- config.setup_minimum_hours_before_start = Rails.application.secrets.dig(:elections, :setup_minimum_hours_before_start).presence || 3
476
+ config.setup_minimum_hours_before_start = Rails.application.secrets.dig(:elections, :setup_minimum_hours_before_start).presence || 1
467
477
  config.start_vote_maximum_hours_before_start = Rails.application.secrets.dig(:elections, :start_vote_maximum_hours_before_start).presence || 6
468
478
  config.voter_token_expiration_minutes = Rails.application.secrets.dig(:elections, :voter_token_expiration_minutes).presence || 120
479
+ config.document_types = Rails.application.secrets.dig(:elections, :document_types).presence || %w(identification_number passport)
469
480
  end
470
481
 
471
482
  Decidim::Votings.configure do |config|
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if Rails.env.development?
3
+ if Rails.env.development? && !Rails.application.config.try(:boost_performance)
4
4
  require "rack-mini-profiler"
5
5
 
6
6
  # initialization is skipped so trigger it
7
7
  Rack::MiniProfilerRails.initialize!(Rails.application)
8
+ Rack::MiniProfiler.config.skip_paths << "/favicon.ico"
8
9
  end
@@ -4,11 +4,11 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
 
6
6
  # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
7
+ # no regular words or you will be exposed to dictionary attacks.
8
8
  # You can use `rails secret` to generate a secure secret key.
9
9
 
10
10
  # Make sure the secrets in this file are kept private
11
- # if you're sharing your code publicly.
11
+ # if you are sharing your code publicly.
12
12
 
13
13
  decidim_default: &decidim_default
14
14
  application_name: <%%= Decidim::Env.new("DECIDIM_APPLICATION_NAME", "My Application Name").to_json %>
@@ -38,9 +38,12 @@ decidim_default: &decidim_default
38
38
  enable_remember_me: <%%= Decidim::Env.new("DECIDIM_ENABLE_REMEMBER_ME", "auto").default_or_present_if_exists.to_s %>
39
39
  follow_http_x_forwarded_host: <%%= Decidim::Env.new("DECIDIM_FOLLOW_HTTP_X_FORWARDED_HOST").to_boolean_string %>
40
40
  maximum_conversation_message_length: <%%= Decidim::Env.new("DECIDIM_MAXIMUM_CONVERSATION_MESSAGE_LENGTH", "1000").to_i %>
41
- password_blacklist: <%%= Decidim::Env.new("DECIDIM_PASSWORD_BLACKLIST").to_array(separator: ", ").to_json %>
41
+ password_similarity_length: <%%= Decidim::Env.new("DECIDIM_PASSWORD_SIMILARITY_LENGTH", 4).to_i %>
42
+ denied_passwords: <%%= Decidim::Env.new("DECIDIM_DENIED_PASSWORDS").to_array(separator: ", ").to_json %>
42
43
  allow_open_redirects: <%%= Decidim::Env.new("DECIDIM_ALLOW_OPEN_REDIRECTS").to_boolean_string %>
44
+ social_share_services: <%%= Decidim::Env.new("DECIDIM_SOCIAL_SHARE_SERVICES", "X, Facebook, WhatsApp, Telegram").to_array.to_json %>
43
45
  service_worker_enabled: <%%= Decidim::Env.new("DECIDIM_SERVICE_WORKER_ENABLED", Rails.env.exclude?("development")).to_boolean_string %>
46
+ page_blocks: <%%= Decidim::Env.new("DECIDIM_PAGE_BLOCKS", "terms-of-service").to_array %>
44
47
  admin_password:
45
48
  expiration_days: <%%= Decidim::Env.new("DECIDIM_ADMIN_PASSWORD_EXPIRATION_DAYS", 90).to_i %>
46
49
  min_length: <%%= Decidim::Env.new("DECIDIM_ADMIN_PASSWORD_MIN_LENGTH", 15).to_i %>
@@ -63,8 +66,6 @@ decidim_default: &decidim_default
63
66
  enable_proposal_linking: <%%= Decidim::Env.new("BUDGETS_ENABLE_PROPOSAL_LINKING", "auto").default_or_present_if_exists.to_s %>
64
67
  accountability:
65
68
  enable_proposal_linking: <%%= Decidim::Env.new("ACCOUNTABILITY_ENABLE_PROPOSAL_LINKING", "auto").default_or_present_if_exists.to_s %>
66
- consultations:
67
- stats_cache_expiration_time: <%%= Decidim::Env.new("CONSULTATIONS_STATS_CACHE_EXPIRATION_TIME", 5).to_i %>
68
69
  initiatives:
69
70
  creation_enabled: <%%= Decidim::Env.new("INITIATIVES_CREATION_ENABLED", "auto").default_or_present_if_exists.to_s %>
70
71
  similarity_threshold: <%%= Decidim::Env.new("INITIATIVES_SIMILARITY_THRESHOLD", 0.25).to_f %>
@@ -88,6 +89,8 @@ elections_default: &elections_default
88
89
  scheme_name: "dummy"
89
90
  quorum: 2
90
91
  number_of_trustees: 3
92
+ setup_minimum_hours_before_start: 1
93
+ document_types: <%%= Decidim::Env.new("ELECTIONS_DOCUMENT_TYPES", "identification_number,passport").to_array.to_json %>
91
94
 
92
95
  storage_default: &storage_default
93
96
  provider: <%%= Decidim::Env.new("STORAGE_PROVIDER", "local").to_s %>
@@ -124,13 +127,15 @@ default: &default
124
127
  enabled: <%%= Decidim::Env.new("OMNIAUTH_FACEBOOK_APP_ID").to_boolean_string %>
125
128
  app_id: <%%= ENV["OMNIAUTH_FACEBOOK_APP_ID"] %>
126
129
  app_secret: <%%= ENV["OMNIAUTH_FACEBOOK_APP_SECRET"] %>
130
+ icon: facebook-fill
127
131
  twitter:
128
132
  enabled: <%%= Decidim::Env.new("OMNIAUTH_TWITTER_API_KEY").to_boolean_string %>
129
133
  api_key: <%%= ENV["OMNIAUTH_TWITTER_API_KEY"] %>
130
134
  api_secret: <%%= ENV["OMNIAUTH_TWITTER_API_SECRET"] %>
135
+ icon: twitter-x-fill
131
136
  google_oauth2:
132
137
  enabled: <%%= Decidim::Env.new("OMNIAUTH_GOOGLE_CLIENT_ID").to_boolean_string %>
133
- icon_path: decidim/brands/google.svg
138
+ icon: google-fill
134
139
  client_id: <%%= ENV["OMNIAUTH_GOOGLE_CLIENT_ID"] %>
135
140
  client_secret: <%%= ENV["OMNIAUTH_GOOGLE_CLIENT_SECRET"] %>
136
141
  maps:
@@ -162,7 +167,7 @@ development:
162
167
  omniauth:
163
168
  developer:
164
169
  enabled: true
165
- icon: phone
170
+ icon: phone-line
166
171
 
167
172
  test:
168
173
  <<: *default
@@ -206,9 +211,10 @@ production:
206
211
  scheme_name: <%%= Decidim::Env.new("ELECTIONS_SCHEME_NAME", "electionguard").to_s %>
207
212
  number_of_trustees: <%%= Decidim::Env.new("ELECTIONS_NUMBER_OF_TRUSTEES").to_i %>
208
213
  quorum: <%%= Decidim::Env.new("ELECTIONS_QUORUM").to_i %>
209
- setup_minimum_hours_before_start: <%%= Decidim::Env.new("ELECTIONS_SETUP_MINIMUM_HOURS_BEFORE_START", 3).to_i %>
214
+ setup_minimum_hours_before_start: <%%= Decidim::Env.new("ELECTIONS_SETUP_MINIMUM_HOURS_BEFORE_START", 1).to_i %>
210
215
  start_vote_maximum_hours_before_start: <%%= Decidim::Env.new("ELECTIONS_START_VOTE_MAXIMUM_HOURS_BEFORE_START", 6).to_i %>
211
216
  voter_token_expiration_minutes: <%%= Decidim::Env.new("ELECTIONS_VOTER_TOKEN_EXPIRATION_MINUTES", 120).to_i %>
217
+ document_types: <%%= Decidim::Env.new("ELECTIONS_DOCUMENT_TYPES", "identification_number,passport").to_array.to_json %>
212
218
  votings:
213
219
  check_census_max_requests: <%%= Decidim::Env.new("VOTINGS_CHECK_CENSUS_MAX_REQUESTS", 5).to_i %>
214
220
  throttling_period: <%%= Decidim::Env.new("VOTINGS_THROTTLING_PERIOD", 1).to_i %>
@@ -3,15 +3,26 @@
3
3
 
4
4
  require "bundler"
5
5
  require "thor"
6
+ require "json"
6
7
  require "active_support/inflector"
7
8
  require "decidim/core/version"
9
+ require "decidim/generators"
8
10
 
9
11
  module Decidim
10
12
  module Generators
11
13
  class ComponentGenerator < Thor
12
14
  include Thor::Actions
13
15
 
14
- attr_reader :component_name, :component_module_name, :component_resource_name, :component_folder, :component_description, :core_version
16
+ attr_reader :component_name,
17
+ :component_module_name,
18
+ :component_resource_name,
19
+ :component_folder,
20
+ :component_description,
21
+ :core_version,
22
+ :npm_package_version,
23
+ :required_ruby_version,
24
+ :security_email,
25
+ :edge_git_branch
15
26
 
16
27
  source_root File.expand_path("component_templates", __dir__)
17
28
 
@@ -24,7 +35,12 @@ module Decidim
24
35
  @component_module_name = component_name.camelize
25
36
  @component_folder = options[:destination_folder] || "decidim-module-#{component_name}"
26
37
  @core_version = Decidim::Core.version
38
+ @npm_package_version = "^#{semver_friendly_version}"
39
+ @edge_git_branch = Decidim::Generators.edge_git_branch
27
40
  @component_description = ask "Write a description for the new component:"
41
+ @required_ruby_version = RUBY_VERSION.length == 5 ? RUBY_VERSION[0..2] : RUBY_VERSION
42
+ @security_email = ask "Provide a public email in case of security concern:"
43
+ format_email!
28
44
 
29
45
  template "decidim-component.gemspec.erb", "#{component_folder}/decidim-#{component_name}.gemspec"
30
46
  template "Gemfile.erb", "#{component_folder}/Gemfile" if options[:external]
@@ -32,7 +48,13 @@ module Decidim
32
48
  template "LICENSE-AGPLv3.txt", "#{component_folder}/LICENSE-AGPLv3.txt"
33
49
  template "README.md.erb", "#{component_folder}/README.md"
34
50
  template "gitignore", "#{component_folder}/.gitignore"
35
- template "circleci/config.yml", "#{component_folder}/.circleci/config.yml"
51
+ template "github/ci.yml.erb", "#{component_folder}/.github/workflows/ci_#{component_name}.yml"
52
+ template "package.json.erb", "#{component_folder}/package.json"
53
+ copy_file ".ruby-version", "#{component_folder}/.ruby-version"
54
+ copy_file ".node-version", "#{component_folder}/.node-version"
55
+ copy_file ".rubocop.yml", "#{component_folder}/.rubocop.yml"
56
+ copy_file ".eslintrc.json", "#{component_folder}/.eslintrc.json"
57
+ copy_file ".stylelintrc.json", "#{component_folder}/.stylelintrc.json"
36
58
 
37
59
  app_folder = "#{component_folder}/app"
38
60
  template "app/packs/js/entrypoint.js", "#{app_folder}/packs/entrypoints/decidim_#{component_name}.js"
@@ -42,6 +64,7 @@ module Decidim
42
64
  template "app/controllers/decidim/component/admin/application_controller.rb.erb", "#{app_folder}/controllers/decidim/#{component_name}/admin/application_controller.rb"
43
65
  template "app/helpers/decidim/component/application_helper.rb.erb", "#{app_folder}/helpers/decidim/#{component_name}/application_helper.rb"
44
66
  template "app/models/decidim/component/application_record.rb.erb", "#{app_folder}/models/decidim/#{component_name}/application_record.rb"
67
+ template "app/permissions/decidim/component/admin/permissions.rb.erb", "#{app_folder}/permissions/decidim/#{component_name}/admin/permissions.rb"
45
68
 
46
69
  bin_folder = "#{component_folder}/bin"
47
70
  template "bin/rails.erb", "#{bin_folder}/rails"
@@ -64,13 +87,32 @@ module Decidim
64
87
  spec_folder = "#{component_folder}/spec"
65
88
  template "spec/spec_helper.rb.erb", "#{spec_folder}/spec_helper.rb"
66
89
  template "spec/factories.rb.erb", "#{spec_folder}/factories.rb"
90
+ template "spec/permissions/admin/permissions_spec.rb.erb", "#{spec_folder}/permissions/admin/permissions_spec.rb"
91
+ template "spec/lib/version_spec.rb.erb", "#{spec_folder}/lib/decidim/#{component_name}/version_spec.rb"
67
92
 
68
93
  if options[:external]
69
94
  inside(component_folder) do
70
95
  Bundler.with_original_env { run "bundle install" }
96
+ Bundler.with_original_env { run "bundle lock --add-platform x86_64-linux" }
97
+ Bundler.with_original_env { run "bundle lock --add-platform ruby" }
71
98
  end
72
99
  end
73
100
  end
101
+
102
+ private
103
+
104
+ def format_email!
105
+ return unless @security_email&.include?("@")
106
+
107
+ split = @security_email.split("@")
108
+ email = split.first
109
+ domain = split.last.gsub(".", " [dot] ")
110
+ @security_email = "#{email} [at] #{domain}"
111
+ end
112
+
113
+ def semver_friendly_version
114
+ Decidim::Generators.version.gsub(/\.pre/, "-pre").gsub(/\.dev/, "-dev").gsub(/.rc(\d*)/, "-rc\\1")
115
+ end
74
116
  end
75
117
  end
76
118
  end
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@decidim"]
3
+ }
@@ -0,0 +1,2 @@
1
+ inherit_gem:
2
+ decidim-dev: rubocop-decidim.yml
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@decidim/stylelint-config"]
3
+ }
@@ -23,7 +23,13 @@ bundle
23
23
 
24
24
  ## Contributing
25
25
 
26
- See [Decidim](https://github.com/decidim/decidim).
26
+ Contributions are welcome !
27
+
28
+ We expect the contributions to follow the [Decidim's contribution guide](https://github.com/decidim/decidim/blob/develop/CONTRIBUTING.adoc).
29
+
30
+ ## Security
31
+
32
+ Security is very important to us. If you have any issue regarding security, please disclose the information responsibly by sending an email to __<%= security_email %>__ and not by creating a Github issue.
27
33
 
28
34
  ## License
29
35