Problem/Motivation
Working on core requires almost certainly drush or console to make it easy to reinstall the site or just install/uninstall a specific module.
At the same time, it became hard to install drush/console globally, for good reasons. They need to sync up the dependencies with core, especially when you switch from 8.3.x to 8.4.x for example.
Proposed resolution
Given that I propose to ship with command line applications for the following three tasks, which are helpful for developing on core. Note the difference to a general command line application useful for working on actual sites.
- Install drupal
- Install/uninstall a module
- Rebuild all caches
This proposal is designed to be limited in scope: Not a generic framework for commands, no discovery method ...
https://symfony.com/doc/current/components/console/single_command_tool.html or http://robo.li/ might help here.
Remaining tasks
- Agree that this is useful
- Ensure that we limit the scope
- Sign off
- Implement it
- Get it in
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|
Issue fork drupal-2894476
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:
- 2894476-provide-commands-which
changes, plain diff MR !2191
Comments
Comment #2
larowlanMakefile
Comment #3
dawehner@larowlan
Do you mind to elaborate a bit? What do you mean exactly with that.
Comment #4
larowlanSorry, meant to paste link https://github.com/alexpott/d8githooks/issues/21
Comment #5
berdirSuch a makefile is just a neat way of storing aliases.
The point of this issue is to have core offer a replacement for drush en some_module (for example) that doesn't actually require drush. A Makefile isn't going to help here as you need something to bootstrap Drupal and call the module installer with the provided argument. Your makefile could just offer a shorter way of calling that command then although it should be as simple as ./scripts/enable-module views.
Comment #6
larowlanright, I've missed the point then - carry on :)
Comment #12
mradcliffeHere's the start of a patch that adds an optional db-url option to the wonderful install command that's already done. The default is the current sqlite usage.
Probably this should be split into an issue for each command. I couldn't find another issue that is more recent.
My reason to come back to this is that it's getting hard to juggle local drush/console and core development for novice contributors. I think this would help a lot to simplify quicksprint tools. In that use case, the environment is setup already and a script runs commands for the user to install the site (requested by mentors that novices have the environment with Drupal already installed).
Comment #13
mradcliffeBack to needs work because it's not complete even though it passes current tests.
Should be
sqlite://localhost/.sqliteas site path will get prefixed anyway.Comment #14
prabha1997 commentedI am working on this issue
Comment #15
prabha1997 commentedComment #16
mradcliffeI re-rolled #15 because I wasn't able to apply the patch on 8.9.x anymore. I'm going to try to work on a test for this today.
Comment #17
mradcliffeLooking at how we would be able to get a test written. I think that db-url is probably not the right parameter name because it does not give a chance to add prefix.
I think there was a movement to get rid of db urls in general so it probably wouldn't make sense to introduce it here.
A JSON string isn't really usable so I guess multiple options for
driver, user, password, port, host, database name and prefix.
Comment #20
mradcliffeI updated the patch to splits db-url option into the parts that can be set in the core installer tasks form. I'm getting 1 fail locally so flipping to Needs review to see if I can replicate on the testbot and then back to Needs work if it passes.
I tried to refactor QuickStartTest::tearDown per the @todo in #2926633: Provide a script to install a Drupal testsite for writing a InstallCommandTestBase that could test each core driver functionally, but I didn't get too far.
@xjm suggested creating issues for each common command in #3089277: Provide core CLI commands for the most common features of Drush (#36) so maybe just focusing on quick-start / install refactor and additional tests would be good scope for this issue? Most of the commands are implemented with the separate console app in #2242947: Integrate Symfony Console component to natively support command line operations.
Comment #21
mradcliffeMysql and Sqlite don't have any test regressions though on the testbot, yay. Back to Needs work for tests.
Comment #22
mradcliffeIt looks like I couldn't instantiate and run the TestSiteApplication class directly without phpunit AbstractPhpProcess dying. I followed the only usage in core by running test-site.php in a separate process.
This patch refactors QuickStartTest to use new InstallCommandTestBase base test class.
Comment #23
mradcliffeShortcuts are short options, not aliases. Maybe just leave NULL for now since there are a lot of short options to come up with letters and numbers for.
Form name is collapsed as "DRIVER[host]" not "DRIVER[advanced_options][host]".
Comment #24
mradcliffe- Added a basic install command tests for mysql and pgsql drivers.
- Fixed issues in #23.
Need to add functional tests to assert error messages returned from missing or bad options.
Comment #25
mradcliffeI guess this fails the test rather than skipping it. Maybe should change to an extension_loaded check?
Comment #28
mradcliffeMaybe instead of making multiple (skipped) tests for each driver, it should just be one test and our test infrastructure ensures it works for each core driver...
It looks like I forgot to pass in host. That'll be a good negative test case to add.
Comment #30
mradcliffeThis should resolve getting the test started on drupalci.
Comment #32
mradcliffeI'm not sure why it's getting stock on the language page. This isn't happening on the quick start test though quick-start is always passing in langcode. However, I was able to reproduce the test failure locally and passing langcode didn't help. It doesn't seem to be an issue with the InputOption::VALUE_OPTIONAL (which should be VALUE_REQUIRED because an input options are always optional and that state means that langcode _could_ be NULL if --langcode is provided). But despite all of that the test is still getting stuck on the Choose language page.
I also added a second test to test Spanish in order to expand the test coverage.
Both are probably going to fail at the language page, but QuickStartTest still succeeds (probably because the wrapped command passes langcode as an InputArray?).
Comment #34
mradcliffeI had figured that the installer wasn't working at all, but it was, and the request redirected to the install page because it didn't detect a valid install.
Removing the tearDown reveals a valid site that works when doing
ln -s sites/simpletest/MY_PREFIX/settings.php sites/default/settings.phpSo something mus tbe wrong with the base url used or detecting that the site should use a the test database.
A consequence of this change is that run-tests.sh --keep-results and --die-on-fail are no longer viable as the tearDown method will remove the site.
Comment #35
mradcliffePatch no longer applies. After I re-rolled, I stumbled across the misnamed QuickStartTestBase and the BuildTests test suite. If we write the install command tests based on that test suite, then we won't need to worry about as much cleanup! Unfortunately (and ironically) QuickStartTest can't be migrated to use QuickStartTestBase because BuildTests creates a php server on its own. It might be worth it to do it as a follow-up. I reverted that part of #32, and focused soley on InstallCommandTest.
Note that despite its name QuickStartTestBase only uses the install command and not the quick-start command. I changed the documentation to be less confusing.
Comment #36
mradcliffePhpStorm autocorrected this incorrectly, and it should be reverted :(
I was going to bump the timeout of the process, but it looks like things are passing for me locally.
This probably can be reverted or maybe put into use?
Comment #37
mradcliffeThis patch removes changes from BuildTestBase, moves the pdo_sqlite extension requirement into the QuickStart command rather than the InstallCommand, and adds InstallCommandTest coverage for site already installed. I removed the explicit langcode option as it should come across as the default option for InstallCommand.
Comment #40
andypostthis kind of fixes better off to separate issue
Comment #41
yogeshmpawarAddressed nitpicks mentioned in #40 & resolved custom commands failures in provided patch
Comment #43
mradcliffeThis isn't right. We do want to test the install in a different language using a non-default langcode. This should be reverted.
The major issue with the patch is that test classes don't create an environment correctly and the test environment is mutated.
Comment #46
mradcliffeHiding patches after opening merge request.
Applied a suggestion from @Mile23.
Comment #51
mradcliffeI think this should be postponed on #3453474: CLI entry point in Drupal Core, and possibly closed as duplicate in favor of multiple issues per command to reduce scope.
Comment #52
mradcliffeClosing as outdated. Some of the work on the install refactor I did probably can be used in a child issue of #3582246: [meta] CLI in Core community initiative.