decidim 0.24.0 → 0.25.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -6
  3. data/babel.config.json +30 -0
  4. data/decidim-core/lib/decidim/webpacker/configuration.rb +89 -0
  5. data/decidim-core/lib/decidim/webpacker/postcss.config.js +16 -0
  6. data/decidim-core/lib/decidim/webpacker/runner.rb +24 -0
  7. data/decidim-core/lib/decidim/webpacker/webpack/base.js +6 -0
  8. data/decidim-core/lib/decidim/webpacker/webpack/custom.js +97 -0
  9. data/decidim-core/lib/decidim/webpacker/webpack/development.js +7 -0
  10. data/decidim-core/lib/decidim/webpacker/webpack/production.js +7 -0
  11. data/decidim-core/lib/decidim/webpacker/webpack/test.js +7 -0
  12. data/decidim-core/lib/decidim/webpacker/webpacker.yml +68 -0
  13. data/docs/README.adoc +1 -1
  14. data/docs/modules/configure/pages/initializer.adoc +31 -0
  15. data/docs/modules/customize/assets/images/modified_user_menu.png +0 -0
  16. data/docs/modules/customize/assets/images/original_user_menu.png +0 -0
  17. data/docs/modules/customize/pages/code.adoc +4 -1
  18. data/docs/modules/customize/pages/images.adoc +2 -2
  19. data/docs/modules/customize/pages/javascript.adoc +8 -3
  20. data/docs/modules/customize/pages/menu.adoc +56 -0
  21. data/docs/modules/customize/pages/styles.adoc +6 -3
  22. data/docs/modules/develop/pages/components.adoc +30 -0
  23. data/docs/modules/develop/pages/guide_migrate_webpacker_app.adoc +175 -0
  24. data/docs/modules/develop/pages/guide_migrate_webpacker_module.adoc +121 -0
  25. data/docs/modules/develop/pages/maps.adoc +2 -2
  26. data/docs/modules/develop/pages/newsletter_templates.adoc +1 -1
  27. data/docs/modules/develop/pages/releases.adoc +3 -1
  28. data/docs/modules/develop/pages/testing.adoc +11 -0
  29. data/docs/modules/develop/pages/view_models_aka_cells.adoc +1 -12
  30. data/docs/modules/install/pages/manual.adoc +46 -43
  31. data/docs/modules/install/pages/update.adoc +1 -1
  32. data/docs/modules/services/pages/elections_bulletin_board.adoc +19 -16
  33. data/docs/modules/services/pages/social_providers.adoc +1 -1
  34. data/lib/decidim.rb +0 -4
  35. data/lib/decidim/version.rb +1 -1
  36. data/lib/tasks/decidim_tasks.rake +92 -0
  37. data/package-lock.json +38919 -0
  38. data/package.json +67 -0
  39. data/packages/all/package.json +22 -0
  40. data/packages/browserslist-config/index.js +7 -0
  41. data/packages/browserslist-config/package.json +17 -0
  42. data/packages/core/package.json +53 -0
  43. data/packages/dev/package.json +21 -0
  44. data/packages/elections/package.json +21 -0
  45. data/packages/eslint-config/index.js +278 -0
  46. data/packages/eslint-config/package.json +28 -0
  47. data/packages/stylelint-config/index.js +160 -0
  48. data/packages/stylelint-config/package.json +20 -0
  49. data/packages/webpacker/index.js +6 -0
  50. data/packages/webpacker/package.json +55 -0
  51. data/packages/webpacker/src/override-config.js +50 -0
  52. metadata +83 -47
@@ -186,7 +186,7 @@ module Decidim
186
186
  # autocompletion functionality in the front-end:
187
187
  class Builder < Decidim::Map::Autocomplete::Builder
188
188
  def javascript_snippets
189
- template.javascript_include_tag("decidim/geocoding/provider/your_provider")
189
+ template.javascript_pack_tag("decidim/geocoding/provider/your_provider")
190
190
  end
191
191
  end
192
192
  end
@@ -196,7 +196,7 @@ module Decidim
196
196
  end
197
197
  ----
198
198
 
199
- To see an example of the front-end JavaScript code that handles the geocoding requests, you can take a look at the link:/decidim-core/app/assets/javascripts/decidim/geocoding/provider/here.js.es6[HERE Maps example].
199
+ To see an example of the front-end JavaScript code that handles the geocoding requests, you can take a look at the link:/decidim-core/app/packs/src/decidim/geocoding/provider/here.js.es6[HERE Maps example].
200
200
  You will have to listen to the `geocoder-suggest.decidim` JavaScript event on all elements that have the `data-decidim-geocoding` attribute defined which contains all the configurations returned by the builder's `builder_options` method as mentioned above.
201
201
  For example, if you passed the following configuration from that method:
202
202
 
@@ -19,7 +19,7 @@ Decidim.content_blocks.register(:newsletter_template, :my_template) do |content_
19
19
  {
20
20
  name: :main_image,
21
21
  uploader: "Decidim::NewsletterTemplateImageUploader",
22
- preview: -> { ActionController::Base.helpers.asset_path("decidim/placeholder.jpg") }
22
+ preview: -> { ActionController::Base.helpers.asset_pack_path("media/images/placeholder.jpg") }
23
23
  }
24
24
  ]
25
25
 
@@ -74,9 +74,11 @@ Running it as is, or passing it the `--help` flag, will render the help section
74
74
  bin/changelog_generator <GITHUB_TOKEN> <SHA>
75
75
  ----
76
76
 
77
+ This command will create a `temporary_changelog.md` in the root of the project, so you can inspect this file and generated changelog.
78
+
77
79
  If you have some elements in the `Unsorted` section of the output, you can review the PRs individually, fix the title and the tags and rerun the script. Those PRs with the tags fixed will be automatically sorted. Labelling the PRs as they're opened or merged is encouraged to save some time when producing the changelog.
78
80
 
79
- You can copy-paste the output of the command to the relevant sections of the changelog file.
81
+ You can copy-paste the contents of the temporary changelog file to the relevant sections of the Changelog file.
80
82
 
81
83
  == Release Candidates
82
84
 
@@ -47,3 +47,14 @@ bundle exec rake test_all
47
47
  ----
48
48
 
49
49
  But beware, it takes a long time... :)
50
+
51
+ == Continuous integration
52
+
53
+ The tests are also run when a new commit is added to the `develop` or releases
54
+ branches, or added to a Pull Request. In the latter case, only the tests for
55
+ the modules affected by any the PR commits will be executed.
56
+
57
+ This means that the workflows defined for each module in the folder
58
+ `.github/workflows/` should be always updated with the module's dependencies
59
+ list. The script `.github/workflows/dependencies.sh` can be helpful to keep
60
+ those files updated until we have an automatic process to do it.
@@ -29,21 +29,10 @@ The `label` option accepts this arguments:
29
29
 
30
30
  == Introducing a Card Cell to a `component`
31
31
 
32
- * add *dependency* to "decidim-*.gemspec"
32
+ * Add the module cell paths to cell view paths in `decidim-<module>/lib/decidim/<module>/engine.rb`
33
33
  +
34
34
  [source,rb]
35
35
  ----
36
- s.add_dependency "cells-erb", "~> 0.1.0"
37
- s.add_dependency "cells-rails", "~> 0.0.9"
38
- ----
39
-
40
- * *require* cells in `decidim-<module>/lib/decidim/<module>/engine.rb`
41
- +
42
- [source,rb]
43
- ----
44
- require "cells/rails"
45
- require "cells-erb"
46
-
47
36
  initializer "decidim_<module>.add_cells_view_paths" do
48
37
  Cell::ViewModel.view_paths << File.expand_path("#{Decidim::<Module>::Engine.root}/app/cells")
49
38
  Cell::ViewModel.view_paths << File.expand_path("#{Decidim::<Module>::Engine.root}/app/views") # for partials
@@ -1,40 +1,39 @@
1
1
  = Manual installation tutorial
2
2
 
3
- == Step by step
4
-
5
3
  In order to develop on decidim, you'll need:
6
4
 
7
5
  * *Git* 2.15+
8
- * *PostgreSQL* 9.5+
9
- * *Ruby* 2.5.0 (2.3+ should work just fine, but that's the version we test against)
10
- * *NodeJS* 9.x.x
6
+ * *PostgreSQL* 12.7+
7
+ * *Ruby* 2.7.1
8
+ * *NodeJS* 15.14.x
9
+ * *Npm* 7.7.x
11
10
  * *ImageMagick*
12
11
  * *Chrome* browser and https://sites.google.com/a/chromium.org/chromedriver/[chromedriver].
13
12
 
14
- We're starting with an Ubuntu 16.04 LTS. This is an opinionated guide and YMMV, so if you're free to use the technology that you fell most comfortable on. If you have any doubts and you're blocked you can go and ask on https://gitter.im/decidim/decidim[our Gitter]. We recommend that you follow some Ruby on Rails tutorials (like http://guides.rubyonrails.org/getting_started.html[Getting Started with Ruby on Rails]) and have some knowledge on how gems and engines work.
13
+ We're starting with an Ubuntu 20.04 LTS. This is an opinionated guide, so you're free to use the technology that you are most comfortable. If you have any doubts and you're blocked you can go and ask on https://gitter.im/decidim/decidim[our Gitter].
14
+
15
+ We recommend to have at least some basic proficiency in Ruby on Rails (a good starting point is http://guides.rubyonrails.org/getting_started.html[Getting Started with Ruby on Rails]) and have some knowledge on how gems work.
15
16
 
16
- On this tutorial we'll see how to install rbenv, PostgreSQL and Decidim, and how to configure everything together.
17
+ In this guide, we'll see how to install rbenv, PostgreSQL and, Decidim, and how to configure everything together.
17
18
 
18
- === Installing rbenv
19
+ == 1. Installing rbenv
19
20
 
20
- First we're going to install rbenv, for managing various ruby versions. We're following the guide from https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-16-04[DigitalOcean]. You could also use https://rvm.io/[rvm] as an alternative on this step. On these instruction we're using the latest ruby published version at the moment (2.5.3), but you should check this out on https://www.ruby-lang.org/en/downloads/[Ruby official website].
21
+ First, we're going to install https://github.com/rbenv/rbenv[rbenv], for managing various ruby versions. You could also use https://rvm.io/[rvm] or https://github.com/asdf-vm/asdf[asdf] as alternatives on this step. Mind that at the moment, Decidim isn't compatible with Ruby 3.0.
21
22
 
22
23
  [source,bash]
23
24
  ----
24
25
  sudo apt update
25
- sudo apt install -y build-essential autoconf bison libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev libicu-dev
26
+ sudo apt install -y build-essential git libssl-dev zlib1g-dev
26
27
  git clone https://github.com/rbenv/rbenv.git ~/.rbenv
27
28
  echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
28
29
  echo 'eval "$(rbenv init -)"' >> ~/.bashrc
29
30
  source ~/.bashrc
30
31
  git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
31
- rbenv install 2.5.3
32
- rbenv global 2.5.3
33
- echo "gem: --no-document" > ~/.gemrc
34
- gem install bundler
32
+ rbenv install 2.7.1
33
+ rbenv global 2.7.1
35
34
  ----
36
35
 
37
- === Installing PostgreSQL
36
+ == 2. Installing PostgreSQL
38
37
 
39
38
  Now we're going to install PostgreSQL for the database:
40
39
 
@@ -44,20 +43,19 @@ sudo apt install -y postgresql libpq-dev
44
43
  sudo -u postgres psql -c "CREATE USER decidim_app WITH SUPERUSER CREATEDB NOCREATEROLE PASSWORD 'thepassword'"
45
44
  ----
46
45
 
47
- You need to change the password (on this example is "thepassword") and save it somewhere to configure it later with the application.
46
+ You need to change the password (in this example is "thepassword") and save it somewhere to configure it later with the application.
48
47
 
49
- === Installing Decidim
48
+ == 3. Installing Decidim
50
49
 
51
- Next, we need to install the `decidim` gem:
50
+ Next, we need to install the `decidim` gem with its dependencies:
52
51
 
53
52
  [source,bash]
54
53
  ----
55
- gem install bootsnap
56
- gem install listen
54
+ sudo apt install -y libicu-dev nodejs imagemagick
57
55
  gem install decidim
58
56
  ----
59
57
 
60
- Afterwards, we can create an application with the nice `decidim` executable, where `decidim_application` is your application name (ie decidim.barcelona):
58
+ Then we can create an application with the `decidim` executable, where `decidim_application` is your application name (ie DecidimBarcelona):
61
59
 
62
60
  [source,bash]
63
61
  ----
@@ -69,13 +67,13 @@ We recommend that you save it all on Git.
69
67
 
70
68
  [source,bash]
71
69
  ----
72
- git init .
73
- git commit -m "Initial commit. Generated with Decidim 0.X https://decidim.org"
70
+ git add .
71
+ git commit -m "Initial commit. Generated with Decidim https://decidim.org"
74
72
  ----
75
73
 
76
- === Configure the database
74
+ == 4. Configure the database
77
75
 
78
- You need to modify your secrets (see `config/database.yml`). For this you can use https://github.com/laserlemon/figaro[figaro], https://github.com/bkeepers/dotenv[dotenv] or https://github.com/rbenv/rbenv-vars[rbenv-vars]. You should always be careful of not uploading your plain secrets on git or your version control system. You can also upload the encrypted secrets, using the sekrets gem or if you're on Ruby on Rails greater than 5.1 you can do it natively.
76
+ Modify your secrets (see `config/database.yml`). For this you can use https://github.com/laserlemon/figaro[figaro], https://github.com/bkeepers/dotenv[dotenv] or https://github.com/rbenv/rbenv-vars[rbenv-vars]. You should always be careful of not uploading your plain secrets on git or your version control system. You can also upload the encrypted secrets, using the sekrets gem or if you're on Ruby on Rails greater than 5.1 you can do it natively.
79
77
 
80
78
  For instance, for working with figaro, add this to your `Gemfile`:
81
79
 
@@ -92,13 +90,13 @@ bundle install
92
90
  bundle exec figaro install
93
91
  ----
94
92
 
95
- Next add this to your `config/application.yml`, using the setup the PostgreSQL database name, user and password that you configure before.
93
+ Next, add this to your `config/application.yml`, using the setup PostgreSQL database name, user and, password that you've configured before.
96
94
 
97
95
  [source,yaml]
98
96
  ----
99
97
  DATABASE_HOST: localhost
100
98
  DATABASE_USERNAME: decidim_app
101
- DATABASE_PASSWORD: your_password
99
+ DATABASE_PASSWORD: thepassword
102
100
  ----
103
101
 
104
102
  Finally, save it all to git:
@@ -106,12 +104,12 @@ Finally, save it all to git:
106
104
  [source,bash]
107
105
  ----
108
106
  git add .
109
- git commit -m "Adds figaro configuration management"
107
+ git commit -m "Add figaro configuration management"
110
108
  ----
111
109
 
112
- === Initializing your app for local development
110
+ == 5. Initializing your app for local development
113
111
 
114
- We should now setup your database:
112
+ We should now create your database:
115
113
 
116
114
  [source,bash]
117
115
  ----
@@ -119,29 +117,34 @@ bin/rails db:create db:migrate
119
117
  bin/rails db:seed
120
118
  ----
121
119
 
122
- This will also create some default data so you can start testing the app:
120
+ This will also create some default data so you can start testing the app, with an administrator account with email admin@example.org and password `decidim123456`
123
121
 
124
- * A `Decidim::System::Admin` with email `system@example.org` and password `decidim123456`, to log in at `/system`.
125
- * A `Decidim::Organization` named `Decidim Staging`. You probably want to change its name and hostname to match your needs.
126
- * A `Decidim::User` acting as an admin for the organization, with email `admin@example.org` and password `decidim123456`.
127
- * A `Decidim::User` that also belongs to the organization but it's a regular user, with email `user@example.org` and password `decidim123456`.
122
+ == 6. Start your web server
128
123
 
129
- This data won't be created in production environments, if you still want to do it, run:
124
+ You can now start your server!
130
125
 
131
126
  [source,bash]
132
127
  ----
133
- SEED=true rails db:setup
128
+ bin/rails s
134
129
  ----
135
130
 
136
- ==== Notes
131
+ Visit http://localhost:3000 to see your app running. 🎉 🎉
137
132
 
138
- When you run `bin/rails db:migrate` you should see a lot of output. If you don't, or if you run into errors seeding your database, try runnning `bin/rake decidim:upgrade` before.
133
+ [NOTE]
134
+ ====
135
+ With these steps you would only have an initial installation for trying Decidim, but it still needs lots of things to take in account. If you want a working production system then we recommend that you follow the https://platoniq.github.io/decidim-install/[Decidim Install guide by Platoniq].
136
+ ====
139
137
 
140
- You can now start your server!
138
+ == Extra notes
139
+
140
+ Other user accounts that you'll have in the seeds are:
141
+
142
+ * To participate as a regular user, with email `user@example.org` and password `decidim123456`.
143
+ * To manage the Multitenant and being able to log in at `/system`, with email `system@example.org` and password `decidim123456`.
144
+
145
+ The seed data won't be created in production environments, if you still want to do it (for instance, for a Demo or Staging server), run:
141
146
 
142
147
  [source,bash]
143
148
  ----
144
- bin/rails s
149
+ SEED=true rails db:seed
145
150
  ----
146
-
147
- Visit http://localhost:3000 to see your app running. 🎉 🎉
@@ -43,7 +43,7 @@ In theory, that would be all. However, you need to be careful in certain situati
43
43
 
44
44
  == From git repositories
45
45
 
46
- For managing the gems we use the standard Rails gem called Bundler, where you can also point to https://bundler.io/v2.1/guides/git.html[git repositories and branches]. This is specially useful if you want to try an unreleased version, then you can do so by pointing to the release branch.
46
+ For managing the gems we use the standard Rails gem called Bundler, where you can also point to https://bundler.io/v2.2/guides/git.html[git repositories and branches]. This is specially useful if you want to try an unreleased version, then you can do so by pointing to the release branch.
47
47
 
48
48
  [source,ruby]
49
49
  ----
@@ -5,11 +5,13 @@
5
5
  This is a work in progress and is not fully working yet.
6
6
  ====
7
7
 
8
- In order to celebrate https://en.wikipedia.org/wiki/End-to-end_auditable_voting_systems[End-to-end auditable votings] using the Elections module, you will need to connect your Decidim instance with an instance of the https://github.com/decidim/decidim-bulletin-board/[Decidim Bulletin Board application], preferably run by an independent organization.
8
+ In order to celebrate https://en.wikipedia.org/wiki/End-to-end_auditable_voting_systems[End-to-end auditable votings] using the Elections module, you will need to connect your Decidim instance with an instance of the https://github.com/decidim/decidim-bulletin-board/[Decidim Bulletin Board application].
9
+
10
+ *Note*: The connected Bulletin Board instance is used by all organizations, therefore it's recommended to set it up by an independent organization.
9
11
 
10
12
  == Identification pair of keys generation
11
13
 
12
- The first step needed to setup the connection is to generate an a pair of keys to identify the application against the Bulletin Board.
14
+ The first step needed to setup the connection is to generate a pair of keys to identify the application against the Bulletin Board.
13
15
  This can be done running the following rake task in your application environment:
14
16
 
15
17
  [source,sh]
@@ -17,32 +19,33 @@ This can be done running the following rake task in your application environment
17
19
  bundle exec rake decidim_elections:generate_identification_keys
18
20
  ----
19
21
 
20
- This task will output the generated private and public keys. You should copy the public key and send it to the Bulletin Board administrator through a secure channel. Together with the key, send your *Authority name* to the Bulletin Board administrator and store its value on the environment variable `BULLETIN_BOARD_AUTHORITY_NAME`.
22
+ This task will output the generated private and public keys. You should copy the public key and send it, together with your *Authority name* to the Bulletin Board administrator through a secure channel. Together with the key, send your *Authority name* to the Bulletin Board administrator.
23
+
24
+ After that, copy the private key and store that value on the environment variable `AUTHORITY_PRIVATE_KEY` and your *Authority name* on the variable `AUTHORITY_NAME`.
21
25
 
22
- After that, copy the private key and store that value on the environment variable `BULLETIN_BOARD_IDENTIFICATION_PRIVATE_KEY`.
26
+ Ensure that the private key is not lost between deployments and servers reboots and that it can only be accessed by the application.
23
27
 
24
- Ensure that the private key is not lost between deployments and servers reboots and that only can be accessed by the application.
28
+ As an administrator of the Bulletin Board, you find the steps to be taken https://github.com/decidim/decidim-bulletin-board/blob/develop/decidim-bulletin_board-app/docs/setup.md#adding-an-authority-as-a-client-of-the-bulletin-board[here].
25
29
 
26
30
  == Configuration of the Bulletin Board application
27
31
 
28
32
  The Bulletin Board administrator will store the received public key in their server and will send you back an API key.
29
- To complete the setup process you should store this API key and the Bulletin Board URL address on the environment variables `BULLETIN_BOARD_API_KEY` and `BULLETIN_BOARD_SERVER`, respectively.
33
+ To complete the setup process you should store this API key and the Bulletin Board URL address on the environment variables `AUTHORITY_API_KEY` and `BULLETIN_BOARD_SERVER`, respectively.
30
34
 
31
35
  The following YAML snippet with all the defined environment variables should be used in the `default` block of your application `config/secrets.yml` file.
32
36
  Maybe this is already done, as it was included in the Decidim applications generator during the development of the Elections module.
33
37
 
34
38
  [source,yaml]
35
39
  ----
36
- bulletin_board:
37
- identification_private_key: <%= ENV["BULLETIN_BOARD_IDENTIFICATION_PRIVATE_KEY"] %>
38
- server: <%= ENV["BULLETIN_BOARD_SERVER"] %>
39
- api_key: <%= ENV["BULLETIN_BOARD_API_KEY"] %>
40
- number_of_trustees: <%= ENV["BULLETIN_BOARD_NUMBER_OF_TRUSTEES"] %>
41
- authority_name: <%= ENV["BULLETIN_BOARD_AUTHORITY_NAME"] %>
42
- scheme:
43
- name: <%= ENV["BULLETIN_BOARD_SCHEME_NAME"] %>
44
- parameters:
45
- quorum: <%= ENV["BULLETIN_BOARD_SCHEME_QUORUM"] %>
40
+ elections:
41
+ bulletin_board_server: <%= ENV["BULLETIN_BOARD_SERVER"] %>
42
+ bulletin_board_public_key: <%= ENV["BULLETIN_BOARD_PUBLIC_KEY"] %>
43
+ authority_api_key: <%= ENV["AUTHORITY_API_KEY"] %>
44
+ authority_name: <%= ENV["AUTHORITY_NAME"] %>
45
+ authority_private_key: <%= ENV["AUTHORITY_PRIVATE_KEY"] %>
46
+ scheme_name: <%= ENV["ELECTIONS_SCHEME_NAME"] %>
47
+ number_of_trustees: <%= ENV["ELECTIONS_NUMBER_OF_TRUSTEES"] %>
48
+ quorum: <%= ENV["ELECTIONS_QUORUM"] %>
46
49
  ----
47
50
 
48
51
  After restarting the Decidim instance, administrator users will be able to create elections on the configured Bulletin Board.
@@ -82,7 +82,7 @@ Instructions in how to configure the client applications can be found in the mod
82
82
  * Or you can create a new strategy, as the https://github.com/decidim/omniauth-decidim[Decidim OmniAuth Strategy]. This strategy allow users from a Decidim instance to login in other Decidim instance. For example, this strategy is used to allow https://decidim.barcelona[decidim.barcelona] users to log into https://meta.decidim.barcelona[meta.decidim.barcelona].
83
83
  * Once you have defined your strategy, you can configure it in the `config/secrets.yml` or in the organization configuration, as it is done for the built-in providers.
84
84
  * By default, Decidim will search in its icons library for an icon named as the provider. You can change this adding an `icon` or `icon_path` attribute to the provider configuration. The `icon` attribute sets the icon name to look for in the Decidim's icons library. The `icon_path` attribute sets the route to the image that should be used.
85
- * Here is an example of the configuration section for the Decidim strategy, using an icon located on the application's `app/assets/images` folder:
85
+ * Here is an example of the configuration section for the Decidim strategy, using an icon located on the application's `app/packs/images` folder:
86
86
 
87
87
  [source,yaml]
88
88
  ----
data/lib/decidim.rb CHANGED
@@ -23,7 +23,3 @@ require "decidim/accountability"
23
23
  require "decidim/debates"
24
24
  require "decidim/sortitions"
25
25
  require "decidim/blogs"
26
-
27
- # Module declaration.
28
- module Decidim
29
- end
@@ -3,6 +3,6 @@
3
3
  # This holds the decidim version and the faker version it uses.
4
4
  module Decidim
5
5
  def self.version
6
- "0.24.0"
6
+ "0.25.0.rc1"
7
7
  end
8
8
  end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ def ensure_log_goes_to_stdout
4
+ old_logger = Webpacker.logger
5
+ Webpacker.logger = ActiveSupport::Logger.new($stdout)
6
+ yield
7
+ ensure
8
+ Webpacker.logger = old_logger
9
+ end
10
+
11
+ namespace :decidim do
12
+ namespace :webpacker do
13
+ desc "Install deps with npm"
14
+ task :npm_install do
15
+ Dir.chdir(File.join(__dir__, "../..")) do
16
+ system "npm install"
17
+ end
18
+ end
19
+
20
+ desc "Compile JavaScript packs using webpack for production with digests"
21
+ task compile: [:npm_install, :environment] do
22
+ Webpacker.with_node_env("production") do
23
+ ensure_log_goes_to_stdout do
24
+ if Decidim.webpacker.commands.compile
25
+ # Successful compilation!
26
+ puts "SUCCESS"
27
+ Dir.chdir(File.join(__dir__, "../..")) do
28
+ system "cp -r public/* #{Rails.root.join("public")}"
29
+ end
30
+ else
31
+ # Failed compilation
32
+ puts "FAIL"
33
+ exit!
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ def npm_install_available?
42
+ rails_major = Rails::VERSION::MAJOR
43
+ rails_minor = Rails::VERSION::MINOR
44
+
45
+ rails_major > 5 || (rails_major == 5 && rails_minor >= 1)
46
+ end
47
+
48
+ def enhance_assets_precompile
49
+ # npm:install was added in Rails 5.1
50
+ deps = npm_install_available? ? [] : ["decidim:webpacker:npm_install"]
51
+ Rake::Task["assets:precompile"].enhance(deps) do
52
+ Rake::Task["decidim:webpacker:compile"].invoke
53
+ end
54
+ end
55
+
56
+ # Compile packs after we've compiled all other assets during precompilation
57
+ skip_webpacker_precompile = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
58
+
59
+ unless skip_webpacker_precompile
60
+ if Rake::Task.task_defined?("assets:precompile")
61
+ enhance_assets_precompile
62
+ else
63
+ Rake::Task.define_task("assets:precompile" => "decidim:webpacker:compile")
64
+ end
65
+ end
66
+
67
+ namespace :decidim do
68
+ namespace :assets do
69
+ desc "Remove 'node_modules' folder"
70
+ task rm_node_modules: :environment do
71
+ Dir.chdir(File.join(__dir__, "../..")) do
72
+ puts "Removing node_modules folder"
73
+ system "rm -rf node_modules"
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ def enhance_assets_clean
80
+ # npm:install was added in Rails 5.1
81
+ Rake::Task["assets:clean"].enhance([]) do
82
+ Rake::Task["decidim:assets:rm_node_modules"].invoke
83
+ end
84
+ end
85
+
86
+ unless skip_webpacker_precompile
87
+ if Rake::Task.task_defined?("assets:clean")
88
+ enhance_assets_clean
89
+ else
90
+ Rake::Task.define_task("assets:clean" => "decidim:assets:rm_node_modules")
91
+ end
92
+ end