One of the original design goals for the Site Audit Drush extension was to provide a tool that could operate on a Drupal site without being installed as part of that site. This characteristic of the 1.x and 2.x branches of Site Audit was very useful in certain environments, e.g. the Pantheon dashboard allows Pantheon users to run static analysis on their Drupal sites without requiring a separate step to install the tool first.
With the advent of the Site Audit 3.x branch, the packaging for Site Audit has switched to a Drupal module. This provides a couple of benefits to Site Audit and non-Pantheon users. First, being a module allows Site Audit commands to utilize third party libraries installed via Composer (if the Drupal site is Composer-managed). This capability is not presently being used by the 3.x branch. The other advantage is that the module packaging allows Site Audit to provide a user interface in the Drupal admin interface; previously, non-Pantheon users only had access to the commandline interface of Site Audit.
The module packaging unfortunately presents the undesirable (for Pantheon) prerequisite that Site Audit be installed in a Drupal site before it can be used. To avoid this prerequisite, Pantheon is now planning on porting the 2.x branch of Site Audit to Drush 9.x. The short-term goal of this work will be to maintain parity with the current features Pantheon users have access to, i.e. the contents of the 2.x branch. The resulting extension is planned to follow the model of https://github.com/drush-ops/example-drush-extension, and as such will run on Drush 9.6.2+ and Drush 8.2.3+.
Moving forward, it might be possible to backport some of the capabilities of the Site Audit 3.x branch to this model. If the use-case of a standalone commandline tool that does not require a module is still of interest here, one technique that might work well would be to put the static analysis functions in the commandline tool, and then include the commandline tool as a dependency of the Drupal 8 module. This would allow the module to instantiate and call the classes and methods of the commandline tool directly without needing to `exec` Drush. In the short term, though, we are only doing the 2.x branch work.
Pantheon is coming in late here; it would have been better to have these conversations 18 months ago. We should have the simple port working shortly. We would prefer to help maintain a public project than create our own fork. We can submit a patch for the 2.x branch if that would be welcome.
Comments
Comment #2
fluxsauce commentedI have no concerns and welcome collaboration to increase compatibility and functionality, either through Drupal.org or GitHub - https://github.com/fluxsauce/site_audit
When I created site_audit when I was working at Pantheon, I designed it to be both useful across the entire platform and to be platform agnostic. I'm no longer active in Drupal, but part of my discussions and vision that I've shared with the current maintainers is about how future versions should maintain those open and flexible capabilities.
In short, PRs and patches are welcome, let's keep growing open-source tools and collaborate to bring a better Drupal experience to all users!
Comment #3
fluxsauce commentedLet me know if you or another Pantheon engineer are interested in co-maintainership, that could facilitate progress.
Comment #4
greg.1.anderson commentedWhich location has more active development, this project on drupal.org, or the GitHub repo?
Comment #5
fluxsauce commentedThey should be in alignment; if they're not, that can be easily rectified. @jrglasgow, can you make sure it's up-to-date? Thanks!
Comment #6
fluxsauce commentedComment #7
jrglasgow commentedI have synced the 8.x-2.x and 8.x.3.x branches on Github.
In thinking about this last year while I was working on the original development of the 8.x-3.x branch I looked into the possibility of having the option of also making the site_audit 8.x-3.x branch work as a non-installed Drush plugin. I think it may be possible if we were able to load the plugins the module uses into the Drupal container. My understanding is that in the bootstrap process the DrupalKernal object, and probably the ContainerInterface for dependency injection get a list of all the plugins declared in installed modules. In theory we might be able to inject the plugins from the site_audit 8.x-3.x module into the dependency injection ContainerInterface and allow the drush to leverage those plugins without forking the module.
Comment #8
greg.1.anderson commentedAn update on where I am at.
I am still planning on using the 2.x branch as the basis for driving my work, as in the short term, strong compatibility with 2.x is critical. However, the 3.x branch has done a lot of cleanup that I do not want to have to re-do in my interim port. So, what I am going to do is identify a 2.x command to port, copy the source code for the appropriate Check from the 3.x branch, make it not a plugin, and wire it up to the Drush command. In my first stage I only care about json output; dealing with reports will happen later.
I have also been thinking about how to reconcile the Plugin architecture from the 3.x branch with a non-module / global Drush command implementation. I think that trying to inject a plugin into Drupal per #7 is not necessary. I'm going to have the Drush command register the built-in commands with simple code that just instantiates the objects and puts them into a simple manager. Later, the plugin code can be wired up to this as a separate way to inject checks into the manager.
At the moment, I think this is better, but I'm only just getting started here. It will be a while before I get to plugins. Are there any contrib modules that are currently using the plugin mechanism to add Site Audit checks?
Comment #9
greg.1.anderson commentedAnother way to state #8 is that I want a Site Audit Plugin to have a 'hasa' relationship with a Site Audit Check, not 'isa'.
The first thing I see that would have to change to make this refactor work would be to make the registry an object, and move `checkInvokeCalculateScore` to the registry.
Comment #10
greg.1.anderson commentedI started an experimental project to work in:
https://github.com/greg-1-anderson/site-audit-tool
Note that this tool works with both Drush 8 and with Drush 9.
Many details are missing / unspecified at this stage; this project shows only how a check may be separated from the Plugin, and how Drush output formatters can render table or json output. TBD items include html output, cross-check-references (currently done via the plugin mechanism) and reports.
Comment #11
greg.1.anderson commentedUpdate on where this is at.
- I moved the Site Audit Tool repository to https://github.com/pantheon-systems/site-audit-tool.
- I ported all of the checks that are being used by the Pantheon dashboard.
- The tool runs some basic tests on all of the checks it supports, using both Drush 9 and Drush 8.
- The code for the checks came from the 8.x-3.x branch, but I made some changes.
- The plugin manager is no longer used to manage checks. Ideally the tool would provide a basic manager, but for now the checks that are available are merely instantiated directly from the commandfile.
- Checks that were returning render arrays were reverted back to the older code from the 7.x-1.x branch to simply insert html.
- Places in the code that needed to do `drush_get_option` now check for attributes of the registry object. I copied options such as 'html' and 'details' into the registry for this purpose.
- I did not use or port any of the report code; instead, I use Drush output formatters to render all output. This means that html mode is not supported in the tool. The html flag will still cause the checks to emit html-embedded-in-json, as `--html --json` previously did.
- I removed the various instances of string padding that were being inserted in non-json mode.
Unfortunately, Pantheon is not interested in sponsoring work on the Drupal module portion of Site Audit. We simply have too many other things competing for our attention right now. If there was interest in sharing checks between the Site Audit Tool and the 8.x-3.x branch, I could probably do some more work to facilitate that. If anyone wants to do that, let me know and I'll outline some steps (integrate with the plugin manager, etc.). It is also possible for 8.x-3.x to continue on in its current form, and leave the Site Audit Tool as a fork.
Anyway, I am sorry that Pantheon didn't pick up this work a year or more ago. It would have been easier to figure out a route forward together earlier.
Comment #12
fluxsauce commentedI'm sorry to hear that Pantheon is unwilling or unable to collaborate on maintaining this utility, which was designed and tested specifically for Pantheon.
The door has been and will always continue to be open.
Comment #13
fluxsauce commentedComment #14
greg.1.anderson commentedPantheon is willing and able to collaborate on maintaining the Drush extension portion of this utility. A drush extension meets the important original use case that Site Audit need not be installed in the Drupal site in order to operate.
For Drupal sites that are not on Pantheon, it makes a lot of sense to have a module that one could install to get a UI to replace the Pantheon Dashboard UI. We can collaborate on making these work together, but we do not have the bandwidth to finish and maintain the incomplete 8.x-3.x branch.
I outlined above how these components could work together. If anyone wants to put time into doing that, I am willing to help.
Comment #15
fluxsauce commentedThanks for the clarification, that sounds less dire.
I have previously given feedback on the 3.x branch about ensuring Drush compatibility and supporting platform-wide (not within the site) installations, and this project will continue to strive towards that. That's how it was originally designed :-)
Comment #16
greg.1.anderson commentedOK, from your reply above it sounds like your current plan is to try to make the module run as not-a-module if installed as a global or site-wide command, and try to initialize and use the plugin manager in this mode as if the code were a module. I think this is a bad idea, and you'll likely discover more reasons why if you try to do this. I think it could ultimately work, but I think it's also at risk of being fragile.
I think that my proposal, to require pantheon-systems/site-audit-tool as a Composer dependency of the Site Audit module would yield better results in the long run. I'm willing to do some work to make a PoC patch, but if I did this it would perhaps cause some extra work for you, as I backed out some of the 8.x-3.x code (using Drupal themes embedded in json output) as mentioned above.
Comment #17
norman.lolI think I'm going to follow @greg.1.anderson's proposal here to Composerize the module and pulling in the actively developed and well-maintained https://github.com/pantheon-systems/site-audit-tool fork as a dependency on top of the work towards an UI that @jrglasgow has done so far into a stable 3.0 release.
By that we can have the best of both worlds. The standalone Drush commands and the checks will be provided by the site audit tool fork and the UI will be provided by the Site Audit module. To onboard users the installation guide must be rewritten in a way that this module and the Drush commands also work for unmanaged projects requiring users to run
composer installafter unzipping the tarball and upload all module files including vendor/.Comment #18
norman.lol