8000 Add CLI command to install a module by jessedobbelaere · Pull Request #3323 · forkcms/forkcms · GitHub
[go: up one dir, main page]

Skip to content

Add CLI command to install a module#3323

Merged
carakas merged 4 commits intoforkcms:masterfrom
jessedobbelaere:add-module-installation-command
May 3, 2021
Merged

Add CLI command to install a module#3323
carakas merged 4 commits intoforkcms:masterfrom
jessedobbelaere:add-module-installation-command

Conversation

@jessedobbelaere
Copy link
Member

Type

  • Enhancement

Resolves the following issues

When I setup CI/CD for a module, I kind of lack

  • Installing Fork CMS using CLI, so i have to load a dump.sql with the base schema of Fork CMS instead and generate the parameters.yml myself.
  • Running the installers of the modules I want to test in my CI/CD. It's kind of cumbersome to dump the module's tables to a dump.sql file and keep the sql dump up to date... because we work with Doctrine entities now anyway. Ideally, I can setup a database, import dump.sql (basic fork cms schema) and then install the module and the theme that I need (locale, tables, images, ...)

Pull request description

This PR adds a command that allows the developer to install a module using his CLI. E.g.

# Show an interactive question with autocomplete
bin/console forkcms:install:module

# Install a module without interaction
bin/console forkcms:install:module Faq

Screenshot 2021-02-27 at 22 34 58

@jessedobbelaere jessedobbelaere requested a review from a team as a code owner February 27, 2021 21:44
@jessedobbelaere jessedobbelaere force-pushed the add-module-installation-command branch from 67ac662 to 80740d0 Compare February 27, 2021 21:47
@codecov
Copy link
codecov bot commented Feb 27, 2021

Codecov Report

Merging #3323 (51f5e8c) into master (3caccf2) will decrease coverage by 0.06%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3323      +/-   ##
============================================
- Coverage     27.79%   27.72%   -0.07%     
- Complexity     8010     8030      +20     
============================================
  Files           568      569       +1     
  Lines         30564    30640      +76     
============================================
  Hits           8496     8496              
- Misses        22068    22144      +76     
Flag Coverage Δ Complexity Δ
functional 23.66% <0.00%> (-0.07%) 0.00 <20.00> (ø)
installer 3.85% <0.00%> (-0.01%) 0.00 <20.00> (ø)
unit 7.61% <0.00%> (-0.02%) 0.00 <20.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...e/InstallerBundle/Console/InstallModuleCommand.php 0.00% <0.00%> (ø) 20.00 <20.00> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3caccf2...f290e7a. Read the comment docs.


// Reboot the kernel to trigger a kernel initialize which registers the Dependency Injection Extension of the
// module we would like to install. Also, make sure to replace the static cached container in our BaseModel!
$_SERVER['INSTALLING_MODULE'] = $module;
Copy link
Member Author
@jessedobbelaere jessedobbelaere Feb 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a while to understand that in the Kernel.php we explicitly listen to the exact route which installs a module, and then we register the DI Extension file of the module.

I need a way to re-initialize the kernel and clearing the cache folder (as suggested here: https://github.com/forkcms/forkcms/blob/master/src/Backend/Modules/Extensions/Actions/InstallModule.php#L41-L43) did not seem to work, probably because the redirect in InstallModule.php creates a brand new request (which boots up the kernel) but here we're dealing in a CLI context. So I reboot the Kernel manually.

Also needed a way to pass the module name to the Kernel.php file to pick up the module name and initialize the DI Extension for it. Feel free to suggest better options than putting it in $_SERVER ? The whole register-module-extension-on-install feels a bit hacky unfortunately

@carakas carakas added this to the 5.10.0 milestone Feb 28, 2021
@carakas carakas merged commit fd7509a into forkcms:master May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0