-
Notifications
You must be signed in to change notification settings - Fork 384
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
Integrate PHP CSS Parser library into plugin and add method to build Composer compatible zip #5745
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5745 +/- ##
=============================================
+ Coverage 75.09% 75.22% +0.13%
+ Complexity 5847 5650 -197
=============================================
Files 234 210 -24
Lines 17667 16977 -690
=============================================
- Hits 13267 12771 -496
+ Misses 4400 4206 -194
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Plugin builds for 2786ae9 are ready 🛎️!
|
Should the AMP PHP Toolbox dependency also be scoped? There could be conflicts with other plugins using it as well.
According to the docs, this I take it that this is the case here?
Curious to learn what's a good solution here... Would it be possible to upload this final ZIP to the Github release, and Composer will get it from there (unless using |
That could be done, yes. I'd only apply that to the non-Composer builds though, since it would only be beneficial in that context.
Yes, the
That could be possible, but you would need a way to tell Composer which of those ZIPs in each release is Composer compatible. I wonder if we could take advantage of Satis in this case to generate a list of package release definitions that would then refer to those releases on GitHub. Here's an example of a GitHub repository that's also being used to host a Composer repository: https://github.com/eventum/composer/tree/master. |
3a2323b
to
4d4b329
Compare
Why only for those builds? What if another plugin on my non-composerized WordPress site also uses AMP PHP Toolbox? I'd want to avoid such conflicts. |
Moving this to v2.2 milestone. |
# Conflicts: # Gruntfile.js # codecov.yml # composer.json # composer.lock
Summary
See #5609
See #2649
This PR modifies the current build setup to produce a Composer compatible zip that can then be referred to in a Composer configuration file. To accomplish this, the following changes were made:
Integrate the PHP CSS Parser library into the plugin. To make this work I took inspiration from the Web Stories plugin and used a tool called PHP-Scoper to move the
sabberworm/php-css-parser
library to a new destination and prefix the namespaces, classes, functions and constants within it to prevent any naming collisions that may occur if another version of the library were to be loaded in the same PHP runtime. The scoped library is also accompanied with a custom Composer autoloader which is then called inamp.php
to load it. All references to the PHP CSS Parser library within the plugin have been updated accordingly to use the scoped version.Add a new npm script called
build:composer
to build a Composer compatible version of the plugin. This is quite trivial to accomplish now that we don't have to worry about the PHP CSS Parser library getting in the way. In essence, the build process has been modified to keep thecomposer.json
file and also update it to include the version of the plugin being built. The version of the plugin has to be set in the file so that Composer knows what version to get when it is being installed as a package.Upload the Composer compatible zip to GCS and add a link to the comment that has the list of links to download each build type.
At the moment, it does not seems possible to publish the plugin on Packagist unless the built assets are going to be committed to a release branch and tagged accordingly (there may be some drawbacks with that approach). Alternatively, we could perhaps take advantage of GCS and setup our own private Composer repository. Upon each release we could upload the Composer compatible zip to a directory dedicated for that use and one could then add a custom repository to their Composer config to reference that URL path. Here's an example of such a config:
Props to @swissspidy for implementing a similar setup in the Web Stories plugin which served as inspiration for what was needed to be done in this plugin.
Checklist