-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special handling for composer-based workflows #284
Conversation
I like the detection for a make path to see if composer should be used. Relates to phase2/generator-gadget#66 |
} | ||
|
||
// Wire up the generated docroot to our custom code. | ||
tasksDefault.push('scaffold'); | ||
|
||
if (grunt.config.get(['composer', 'install'])) { | ||
if (grunt.file.exists('./composer.lock') && grunt.config.get(['composer', 'install'])) { | ||
// Run `composer install` if there is already a lock file. Updates should be explicit once this file exists. | ||
tasksDefault.unshift('composer:install'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to manually run composer drupal-scaffold
here too, or go figure out why Drupal Scaffold removed it.
This is looking good. I'd like to see some test coverage for the composer-based workflow route. Do you have an example configuration? |
I've added tests (which includes an example configuration). I also re-worked some of the d7 example/test assets to reflect that I updated the install task to include |
api = 2 | ||
|
||
; Drupal Core | ||
projects[drupal][version] = "8.0.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping test coverage for Drush Make for D8 implies this should be merged into pre-v1. I'm okay with that.
Overall in favor here, though as mentioned I do think it should be targeted at the 1.0 release. I'm comfortable with the docs as a follow-up but 1.0 blocker if that helps. This does make the particular details of the (generated) composer.json a bigger part of how grunt-drupal-tasks works, as we're relying on some fairly elaborate, non-standard code being triggered by composer management in a way we never did with Drush. The 1.0 docs already focus on Gadget as the way to get started, but this change really makes Gadget almost a requirement. Not sure what the implications are of that, if any. |
I'd like to see this sooner rather than later. The impact on non-composer builds is really minimal and the changes to only run drushmake if there is a makefile in the src just makes good sense regardless. I don't think we are really relying on a lot of "non-standard code" here. The only tricky part I have run into with composer is the drupal-scaffolding stuff which is more of a drupal issue than a composer issue. I've actually created test files without Gadget, so even that isn't really required. This PR is currently a blocker for both a client project as well as our own P2 distro, so I'll help as I can with whatever blockers there are in getting this committed so we can get more people testing composer-based builds. |
Agreed on the significance. Composer drupal-scaffold is what I was referring to, and it makes a key part of building gdt-based projects reliant on gadget. That's not a blocker, more of a philosophical shift which perhaps needs our Readme updated. I'd still like this to be a 1.0 change if possible, will cut down our road map further. |
I'm investigating the drupal-scafoold stuff more today. I'm not sure it requires Gadget actually. The Lightning "pure-composer" build process is working fine without Gadget, so I think there might be an alternative way to handle this. Before Jonathan added the composer:drupal-scaffold I had a site building with Lightning and all the Drupal stuff and need to figure out a way to reproduce what I had working. I'll leave the version issues to you and others since I haven't been involved in the road mapping. |
Interesting point about what drupal-scaffold really gets us. As I understand, it's mostly the particular code repo structure, which is part of GDT function. |
Doesn't Lightning's
It doesn't actually scaffold so much as download all the root files from core that sit alongside the |
So I did some testing of this outside of GDT with just pure composer. Using a composer.json that has this:
So, I don't recommend using For example, even if our composer.json file is pointing to Lighting 1.1.00-rc6, doing a |
That's only true if we commit the files it adds. Otherwise, any subsequent developer would need that to run. It also needs to run when core version is upgraded in case those files have changed (which I think is why it is set to run automatically on a |
The docs encourage committing the scaffolding files, in which case it would only have to run the first time, or on intentional upgrades of core. |
So scaffold stuff is resolved. What is left for this to get merged? Doesn't impact any existing projects, only composer-based stuff. We really need to at least get the "if (grunt.config.get('config.srcPaths.make'))..." condition committed since that is a current blocker for projects that do not have any drush make file. |
|
@grayside I've done the first 2, I have not done the manual merge. I've also updated the corresponding gadget pr with the composer repository change. |
Thanks @jhedstrom, I'm looking forward to getting this in. When testing this today, I found that the I agree with @grayside that this should go into the v1.0.0-pre branch. I'm willing to help with that merge. |
This branch has composer-workflow merged into v1.0.0: https://github.com/phase2/grunt-drupal-tasks/tree/v1.0.0-pre-composer-workflow Tests are looking good: https://travis-ci.org/phase2/grunt-drupal-tasks/builds/137954782 |
This is going to take a bit of work I think. In the pre-composer version, all of the project's production dependencies were able to be packaged since they lived in |
@jhedstrom I can appreciate wanting to keep I ran into this issue when trying to mount the package output at Given the docroot living at So a few questions:
|
I just ran into this with a client that wanted to use our Octane repo example for Lighting/composer. We needed to change the "installer-paths" to be relative to the current dir and get the vendor directory created in the current dir so we could put the entire current dir into a repo for Pantheon. So I think having the vendor dir as close to the docroot as possible makes sense. Projects that need to push an entire repo to a hosting provider will need the vendor dir in the docroot. I think that means the production server probably needs vendor in the docroot. For GDT it seems like maybe we could add a configuration to handle it in different places maybe? |
Package can whitelist/blacklist different directories, as well as move them around. In practice, this means if the docroot knows to look one level up, we can have our composer and package configuration make that so. However, that gets dicey with Pantheon, which will probably require the This also doesn't address the point about development dependencies. While I don't see a harm from including PHPCS, PHPMD, Behat, and so on, it certainly bloats the package size a bit. One thing we could do, after running the package command to shape (copied) release package, we could use the tools installed in the build environment to strip the dev dependencies. It looks like |
As @grayside mentioned, I see that the package task already can be configured to put the build output in paths to preserve the expected relationship. The following changes in Gruntconfig.json will include the vendor directory under the package path and the docroot output under
By symlinking As @mike-potter said, this will not work in environments where you cannot deploy outside of the docroot. To support those environments, the paths in the autoloader files generated by Composer will need to be updated to match the structure of the package output. |
This is merged to master, and available as version 1.0.0-alpha1. It is not tagged as the latest release, so install it by version: |
For use in projects, that probably means |
This is the corresponding PR to phase2/generator-gadget#66