GithubHelp home page GithubHelp logo

inpsyde / vip-composer-plugin Goto Github PK

View Code? Open in Web Editor NEW
11.0 5.0 0.0 574 KB

A Composer plugin to ease deployment to wordpress.com VIP servers alongside Composer-based local development.

License: MIT License

PHP 100.00%
wpcomvip wp deployment deploy ci continous-integration mu-plugins wordpress-folder vip composer-plugin

vip-composer-plugin's People

Contributors

antonioeatgoat avatar chrico avatar gmazzap avatar remyvv avatar spajor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vip-composer-plugin's Issues

Tasks - handling of errors/exceptions in Task::run()

Is your feature request related to a problem? Please describe.

Currently Tasks are added and executed in Command and on exception we stop the execution. But in some cases like in the SymlinkVipGoDir::run() we do not check for successful execution and continue with an errornous results. In other cases we continue the runner, but printing errors, like in DownloadWpCore:run(). We should generalize this and consider, that "critical execution" needs to 100% succeed or otherwhise throw an Exception to stop the program.

Describe the solution you'd like
Following Tasks need to be updated and throw a custom Exception when we cannot ensure that the task 100% completes:

Additional context
See discussion here: #5

Just had a quick review yet..maybe we'll find more. Will update the list when i find one.

[Bug]: Autoload path of packages with type "wordpress-muplugin" is incorrect

Description of the bug

When using this plugin on a composer-project with a dependency of type "wordpress-muplugin" the classmap autoloader created by this plugin does not contain the correct paths to autoloaded files within the plugin folder.

Reproduction instructions

  1. Create WordPress VIP project based on https://github.com/inpsyde/vip-go-website-template
  2. Install dependency with autoloaded classes as wordpress-muplugin
  3. Run composer vip --local --git and inspect /vip/.vipgit%hash%/client-mu-plugins/vendor/vip-autoload/autoload_classmap.php
  4. Notice that the path for the mu-plugin is $baseDir . '/vip/client-mu-plugins/%plugin-name%, which is non-existant.

Expected behavior

I expect installing mu-plugins to work with the production autoload as composer handles it locally with it's own autoload.

Environment info

No response

Relevant log output

No response

Additional context

My proposal is to extend the replacement regex here with the client-mu-plugins directory.
This way the autoloader contains the correct reference again.

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Bug]: Fatal error with `copyDevPaths`

Description of the bug

It looks like the merge c84c73c introduced a bug.

Now the command copyDevPath() fails with a fatal error.

Reproduction instructions

  1. Update the package to the last version.
  2. Try composer vip --sync-dev-paths.

Expected behavior

The command is executed without any error.

Environment info

No response

Relevant log output

The "/Users/mangiaca/Websites/project/vip-config/env" directory does not exist.

#0 /Users/mangiaca/Websites/project/vip/client-mu-plugins/vendor/inpsyde/vip-composer-plugin/src/Task/CopyDevPaths.php(189): Symfony\Component\Finder\Finder->in('/Users/mangiaca...')
#1 /Users/mangiaca/Websites/project/vip/client-mu-plugins/vendor/inpsyde/vip-composer-plugin/src/Task/CopyDevPaths.php(112): Inpsyde\VipComposer\Task\CopyDevPaths->pathInfoForKey('vip-config-dir')
#2 /Users/mangiaca/Websites/project/vip/client-mu-plugins/vendor/inpsyde/vip-composer-plugin/src/Task/CopyDevPaths.php(86): Inpsyde\VipComposer\Task\CopyDevPaths->copyDevPath('vip-config-dir', Object(Inpsyde\VipComposer\Io))
#3 /Users/mangiaca/Websites/project/vip/client-mu-plugins/vendor/inpsyde/vip-composer-plugin/src/Tasks.php(56): Inpsyde\VipComposer\Task\CopyDevPaths->run(Object(Inpsyde\VipComposer\Io), Object(Inpsyde\VipComposer\Task\TaskConfig))
#4 /Users/mangiaca/Websites/project/vip/client-mu-plugins/vendor/inpsyde/vip-composer-plugin/src/Command.php(185): Inpsyde\VipComposer\Tasks->run()
#5 phar:///opt/homebrew/Cellar/composer/2.6.6/bin/composer/vendor/symfony/console/Command/Command.php(298): Inpsyde\VipComposer\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 phar:///opt/homebrew/Cellar/composer/2.6.6/bin/composer/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 phar:///opt/homebrew/Cellar/composer/2.6.6/bin/composer/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(Inpsyde\VipComposer\Command), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 phar:///opt/homebrew/Cellar/composer/2.6.6/bin/composer/src/Composer/Console/Application.php(382): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///opt/homebrew/Cellar/composer/2.6.6/bin/composer/vendor/symfony/console/Application.php(171): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///opt/homebrew/Cellar/composer/2.6.6/bin/composer/src/Composer/Console/Application.php(145): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///opt/homebrew/Cellar/composer/2.6.6/bin/composer/bin/composer(93): Composer\Console\Application->run()
#12 /opt/homebrew/Cellar/composer/2.6.6/bin/composer(29): require('phar:///opt/hom...')
#13 {main}


### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

[Bug]: Missing loaded files

Description of the bug

It looks like that https://github.com/Automattic/vip-go-mu-plugins/blob/develop/000-pre-vip-config/requires.php needs to be loaded locally in wp-config.php or relatively early. Currently our vip-composer-plugin does not take that file into consideration and WP VIP does just leave a comment in the file ๐Ÿค”

You should make sure to include this file locally in case you're not using VIP Local Development Environment

We should add this file (and others...?) to our vip-composer-plugin as files which should be required in wp-config.php.

Reproduction instructions

  1. Create a mu-plugin
  2. do a class_exists(VIP_Request_Block::class)
  3. it will return false because its not autoloaded and the "manual" require_once-file is not added by us.

Expected behavior

Add the /vip-go-mu-plugins/000-pre-vip-config/requires.php to wp-config.php

Environment info

No response

Relevant log output

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Bug]: PHP 8.1 compat

Description of the bug

self::GIT_BRANCH => FILTER_SANITIZE_STRING,

Deprecation Notice: Constant Inpsyde\VipComposer\Task\FILTER_SANITIZE_STRING is deprecated in /home/runner/work/mah-website/mah-website/vip/client-mu-plugins/vendor/inpsyde/vip-composer-plugin/src/Command.php:208

Reproduction instructions

Deploy with PHP 8.1

Expected behavior

Environment info

No response

Relevant log output

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Bug]: Autoloading of files fails with Composer >= 2.3

Description of the bug

Due some change on Composer v2.3 and dropped support of PHP < 7.2 the path for the generated autoload file is not correct anymore.

The change on Composer was following:

v2.3
https://github.com/composer/composer/blob/2.3.0/src/Composer/Autoload/AutoloadGenerator.php#L983

self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(__DIR__));

v.2.2
https://github.com/composer/composer/blob/2.2/src/Composer/Autoload/AutoloadGenerator.php#L985

self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(\\dirname(__FILE__)));

We see now following fatal error:

PHP message: Compile error: require(): Failed opening required /var/www/wp-content/client-mu-plugins/vendor/vip-autoload/../../../../vip/plugins/{snipped}/inc/helpers.php

It seems, the paths is incorrect. ๐Ÿค”

Reproduction instructions

Deploy to VIP with Composer v2.3 and autoload.files in one of the packages.

Expected behavior

Path replacement should work with Composer v2.3.

Environment info

  • inpsyde/vip-composer-plugin 1.4.0
  • PHP 7.4
  • Composer v2.3

Relevant log output

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.