poetapp / wordpress-plugin

Automatically post to the Po.et Network from WordPress
https://wordpress.org/plugins/po-et/
GNU General Public License v2.0
49 stars 32 forks source link

use Composer for package management and PHPCS for code style #40

Closed markparolisi closed 5 years ago

markparolisi commented 5 years ago

This adds support for Composer and PHPCS in an easy build process. Will be used for linting, tests, and packaging for deploys. This just sets up the config

lautarodragan commented 5 years ago

@markparolisi I'm trying to test this using composer wp-package but I'm getting the following error when uploading build.zip to my WP instance:

The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature

I tried running zip build.zip assets includes languages LICENSE poet.php readme.txt instead of tar and that worked a step further, but then failed to activate with:

Warning: require(/opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/build-2/includes/class-poet.php): failed to open stream: No such file or directory in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/build-2/poet.php on line 46

Fatal error: require(): Failed opening required '/opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/build-2/includes/class-poet.php' (include_path='.:/opt/bitnami/php/lib/php') in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/build-2/poet.php on line 46
markparolisi commented 5 years ago

Thanks, @lautarodragan I'll check on that task. I wrote it a while back and I'm sure the plugin has changed and I never actually checked my work there :/ Did you try running the lint command as well?

lautarodragan commented 5 years ago

No worries. Tried a bit and looks like this works:

zip -r poet.zip admin assets includes languages LICENSE poet.php public readme.txt

Seems like the file needs to be a zip, and a couple of directories were missing from the package.

With that I was able to upload and install the plugin: http://54.87.184.5/2018/07/04/is-there-a-bug-in-the-new-version/

I was also able to create a new post and get it anchored: http://54.87.184.5/2018/11/21/plain-truth-is-nothing/

So far so good.

Created a PR to your PR with this fix: https://github.com/poetapp/wordpress-plugin/pull/41/files

re: lint, just tried running it but I'm missing some binaries:

$ composer lint
> phpcs
sh: 1: phpcs: not found
Script phpcs handling the lint event returned with error code 127
$ composer test
> phpunit
sh: 1: phpunit: not found
Script phpunit handling the test event returned with error code 127
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phpunit/php-code-coverage 5.2.0 -> satisfiable by phpunit/php-code-coverage[5.2.0].
    - phpunit/php-code-coverage 5.2.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 2
    - Installation request for phpunit/phpunit 6.0.0 -> satisfiable by phpunit/phpunit[6.0.0].
    - phpunit/phpunit 6.0.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 3
    - Installation request for squizlabs/php_codesniffer 3.3.2 -> satisfiable by squizlabs/php_codesniffer[3.3.2].
    - squizlabs/php_codesniffer 3.3.2 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system.
  Problem 4
    - Installation request for theseer/tokenizer 1.1.0 -> satisfiable by theseer/tokenizer[1.1.0].
    - theseer/tokenizer 1.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 5
    - squizlabs/php_codesniffer 3.3.2 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system.
    - wp-coding-standards/wpcs 1.2.0 requires squizlabs/php_codesniffer ^2.9.0 || ^3.0.2 -> satisfiable by squizlabs/php_codesniffer[3.3.2].
    - Installation request for wp-coding-standards/wpcs 1.2.0 -> satisfiable by wp-coding-standards/wpcs[1.2.0].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.0/cli/php.ini
    - /etc/php/7.0/cli/conf.d/10-opcache.ini
    - /etc/php/7.0/cli/conf.d/10-pdo.ini
    - /etc/php/7.0/cli/conf.d/20-calendar.ini
    - /etc/php/7.0/cli/conf.d/20-ctype.ini
    - /etc/php/7.0/cli/conf.d/20-exif.ini
    - /etc/php/7.0/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.0/cli/conf.d/20-ftp.ini
    - /etc/php/7.0/cli/conf.d/20-gettext.ini
    - /etc/php/7.0/cli/conf.d/20-iconv.ini
    - /etc/php/7.0/cli/conf.d/20-json.ini
    - /etc/php/7.0/cli/conf.d/20-phar.ini
    - /etc/php/7.0/cli/conf.d/20-posix.ini
    - /etc/php/7.0/cli/conf.d/20-readline.ini
    - /etc/php/7.0/cli/conf.d/20-shmop.ini
    - /etc/php/7.0/cli/conf.d/20-sockets.ini
    - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.0/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.0/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.0/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

I want to avoid setting up an environment for PHP development since we don't use it for anything else at Po.et, but eventually we can get Travis to run everything, and maybe add a docker-compose / dockerfile :)

Everything else looks great, love the style improvements.

markparolisi commented 5 years ago

Yeah I'll merge your fixes and get this 100% straightened out. Adding a Travis config and docker-compose will be easy enough as well. Once I get all of the four outstanding PRs all merged (into a v1.0.3 branch) we can run some final tests before packaging for a SVN release.