Problem/Motivation
One important aspect of Project Browser is to actually enable a user / site builder to install the module using the UI.
To do this, they will likely need to run the composer command that brings the project down into their codebase.
The Automatic Update module has been working on providing a generic API module package_manager that will make this process much simpler.
Proposed resolution
Create a service that will use `package_manager` module as a dependency to install the module via Composer
In this issue we will not expose this functionality through the UI but instead #3284945: Install endpoints that leverage Package Manager + core APIs will be updated to use this service when it is finished.
We will create kernel in this issue to prove the installer work. The testing will be able to rely on test classes and patterns from package_manager.
In follow-up issues we will need to create validators to ensure the service installs projects securely and handles various edge cases.
Some of these follow up issues have already been created
- #3249550: Create a validator to ensure core was not updated during a project install
- #3249553: Create package_manager validator to ensure the project to be installed is not already installed by Composer
Basically the service + validator should not have to assume anything about the UI to ensure the installs are secure and stable. This should be ensured on the API level.
Remaining tasks
- ✅ File an issue about this project
- ☐ Addition/Change/Update/Fix to this project
- ☐ Testing to ensure no regression
- ☐ Automated unit/functional testing coverage
- ☐ Developer Documentation support on feature change/addition
- ☐ User Guide Documentation support on feature change/addition
- ☐ Code review from 1 Drupal core team member
- ☐ Full testing and approval
- ☐ Credit contributors
- ☐ Review with the product owner
- ☐ Release
User interface changes
Button to download/install would actually do something. :)
Issue fork project_browser-3245770
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
chrisfromredfinIn the PB meeting from 10/20, @mandclu offered to spearhead this issue.
Comment #3
chrisfromredfinAlso, FYI Ted Bowman (@tedbow) is the point for this at Automatic Updates Initiative.
Comment #4
gaurav.kapoor commentedI’ll give this feature implementation a try. Will update on my progress accordingly.
Comment #7
gaurav.kapoor commentedI have added an MR (Not sure when we create MR in this new workflow, more of a patch person) with a very basic implementation of connection with the Package Manager and also included work/suggestions by @grasmash. It will still require considerable work to take this to the finish line. Looking for suggestions/feedback regarding a few items:
1. I have added this change in the .info.yml file as that's how the Automatic Update module was indicating dependency on Package Manager. But as of now, the Package manager is still isn't part of the core and the user will have to clone 8.x-2.x in local to test the working of this MR.
2. When hitting the download button in the Svelte app, the following issues still have to be addressed:
The Drupal controller doesn't receive value for the project machine name in the request. Some debugging is required in the Svelte code for this.Comment #8
chrisfromredfinFor #1, can we depend on a particular package + version of Package Manager in our composer.json?
Comment #11
tim.plunkettPer discussion in Slack I reverted this commit
Comment #15
tedbowI think we should change this issue to just implementing an API callback that Javascript will use in follow-up to install the module. If we also provide a Functional test to assert the correct response and assert that module was actually enable it should be enough to prove it works. We would need those test anyways.
Comment #16
tedbowSome suggestions for creating a test:
core/modules/editor/tests/src/Functional/EditorSecurityTest.phpWe just create a new module
package_manager_test_validationin #3249983: Create a test module in Package Manager for testing stage validation that you can use(have to pull changes)probably use it something like this
<?
$error = ValidationResult::createError([$message]);
TestSubscriber::setTestResult([$error], PreRequireEvent::class);
project_browserdependent onpackage_manager, we can this optional laterdrupal/automatic_updates:2.x-deva. no errors installs module
b. errors, make sure they come back in json response
c. access error, a user without access should get 403
\Drupal\Tests\automatic_updates\Build\CoreUpdateTestbut can do that laterComment #17
bakulahluwalia@tedbow, thanks for the overview.
Comment #19
fjgarlin commentedI believe this might be a duplicate of https://www.drupal.org/project/project_browser/issues/3284945
Comment #20
chrisfromredfinConfirmed duplicate, chrisfromredfin, fjgarlin, and bnjmnm
Comment #21
tedbowI chatted with @bnjmnn about re-opening this issue.
The way #3284945: Install endpoints that leverage Package Manager + core APIs is currently scoped it will need to create the UI changes needed for actual installs and create the integration with
package_manager. To do this correctly it will also need to create the test coverage for both parts and make sure it is secure. That is a lot for 1 issue.@bnjmnn agreed with me that we should re-open this issue to make the scope of #3284945: Install endpoints that leverage Package Manager + core APIs much smaller.
Also tackling the only the API integration with
package_managerits own issue will keep this issue much smaller in scope and make it much easier to review by myself and/or the other developers that have been working on the Automatic Updates moduleComment #22
tedbowWe have multiple merge requests so I am trying to consolidate the work into 1 branch.
I chose merge request 12 mostly because merge request 62 uses the branch name
1.0.xthat doesn't work well with the "Show commands" boxes at the top of the issue provided by drupal.org.I did cherry-pick all the commits though the commits that @bakulahluwalia made though and brought them over to the MR 12. I also clean up most of 62 to be inline with the testing from 12. The module won't need a controller to test the service as this will be provided by the test module
project_browser_test_api. this will allow this merge request to be much smaller by only providing the new service and the testing for it.A lot of stuff has changed in package_manager since these merge requests were last worked so I will leave notes on the MR
Comment #23
kunal.sachdev commentedComment #24
tedbowCreated #3299285: Change automated tests to use 7.4 and maybe add PHP requirement to 7.4
For now to get the MR to pass test you have to add a PHP 7.4 to this issue instead of 7.3.
The tests are passing now
Comment #25
tedbowSetting to Needs Review as tests are passing using PHP 7.4 which Automatic Updates requires
Comment #26
tedbowComment #27
kunal.sachdev commentedComment #28
fjgarlin commentedI made a couple of questions in the MR and also highlighted the fact that projects might not come from the `drupal/project_name` namespace for composer.
Comment #29
tedbow@fjgarlin thanks for the review. I commented/updated on all your points. Setting back to needs review
We have tests now so removing tag
Comment #30
tedbowComment #32
bnjmnmUpdating IS because the testing workaround is no longer needed.
Comment #36
bnjmnmMR 12 had a very difficult commit history to rebase, so I've moved the current changes to a new MR: 227. The two active threads on MR 12 were moved over as well, in the form of me quoting the originals.
Comment #37
bnjmnmAlright! MR 227 is the one to review
Comment #38
tedbowComment #39
tim.plunkettThis is looking great! A couple points of feedback (which are already being discussed), so I'm changing the status for now.
Comment #40
tedbowAddressed all MR comments
Comment #41
tim.plunkettGreat, thanks @kunal.sachdev and @tedbow! That resolved all my feedback. Leaving at RTBC for a bit just in case someone else chimes in first, but will commit soon.
Comment #43
tim.plunkettAdding phenaproxima who commented on the MR in gitlab.
Comment #45
tim.plunkett9 months after reverting the original MR, we're back with a real API! Thanks everyone!