Skip to content

Latest commit

 

History

History
154 lines (116 loc) · 7.28 KB

DEV-NOTES.md

File metadata and controls

154 lines (116 loc) · 7.28 KB

Decidim::Questions

Cloning Decidim::Proposals

Here's the procedure followed for 0.16 iteration.

this procedure can be improved for sure. Operations are split and isolated in commits. Not sure if git merge algorithms prefer clean operation series (movement/rename then text remplacement) or aggregated ones (movement/rename/replace in the same commit).

For each steps, assume that you are replacing "Proposal" with "Question" ;) !

Step 1 : checking out version

git clone https://github.com/decidim/decidim -b 0.16-stable decidim-questions
cd decidim-questions

Step 2 : Cleaning directories

  • remove all directory except decidim-proposals
  • remove all files at the root except .gitignore

--> see commit 5c80700

Step 3 : Renaming files & directories

3.1 : Renaming main module directory

git mv decidim-proposals decidim-questions

--> see commit 295cfce

3.2 : Creating new directories

git ls-tree -dr HEAD --name-only | grep proposal

--> Use the list to generate commands like
mkdir -p <new-directory>

3.3 : moving files

git ls-files | grep proposal

--> Use the list to generate commands like
git mv <source> <destination>

3.4 : Deleting old directories

git ls-tree -dr HEAD --name-only | grep proposal

--> Use the lists to generate commands like
rm -rf <old-directory>

--> see the gist with full generated commands list

--> see commit ef330ab

Step 4 : Bulk replace text content

with built Search / Replace All from text editor (⚠️Case Sensitive)

  • "Proposal" --> "Question"
  • "proposal" --> "question"
  • "PROPOSAL" --> "QUESTION"

if anyone has the sed / awk command for that one 😉

--> see commit c47e068
We did have a few misfire ...
--> see commit d2cf521
--> see commit 65e1e8f
--> see commit 5ce20d5
--> see commit 0d41054

Step 5 : Moving files up the module directory

git mv decidim-questions/* ./

--> see commit 5e74e9b

Step 6 : Add missing module files from template

We generated an external module from scratch to compare the Proposals module architecture with the generated one.

bundle exec decidim --component questions --external --destination_folder ../decidim-questions/

Important files to be tweaked for your needs are :

--> see commit ff90b17
--> see commit fcb68c4
--> see commit 9756e00
--> see commit 6700707
--> see commit 22ad6b9

Step 7 : Squash migrations

This step could have been done right after Step 1 to be part of the file renaming processes. Principles remains the same.

7.1 : Generate a dummy test app

bundle exec rails test_app

⚠️ At this point, the app generation should crash around the seed part. But we only need to extract the DB schema for now.

7.2 : Get the full schema for Proposals tables

  • Locate the Proposals related tables in the generated ./spec/decidim_dummy_app/db/schema.rb They should be in a single pack of code.
  • Copy the code

7.3 : Create the squashed migration

rm ./db/migrate/*
bundle exec rails generate migration CreateDecidimQuestions

--> Paste the copied code from 7.2

--> see generated migration --> see whole commit 106f56d

Step 8 : Bundle & Tests

Recreate the test app and it to fix the last qwirks.

bundle exec rails test_app
bundle exec rails spec

At this point we did fix :

  • Force class scope on ParticipatoryTextsController
    --> see commit 65dd28e
  • Add some helpers method --> see commit 3f6b7be
    --> see commit 1d6dd1b
  • Extends for Amendable commands to be able to manage other types than Proposals --> see commit fea5cf6
  • Extends for CellsHelper for Questions --> see commit d1b3d14
  • Extends for AuthorCell for Questions --> see commit e0fb9c2

Step 9 : Publish

Push your fresh module to your favorite repository 🚀

git remote add questions https://github.com/OpenSourcePolitics/decidim-questions
git push --set-upstream questions 0.16-stable