wp-cli / scaffold-command

Generates code for post types, taxonomies, blocks, plugins, child themes, etc.
MIT License
165 stars 85 forks source link

Add template/composer.json #63

Closed GaryJones closed 1 year ago

GaryJones commented 6 years ago

Adding a composer.json template would encourage developers to make their plugins available via Packagist, and also allow local install of dependencies.

Currently, WPCS + PHPCS is made available via a global composer install here for Travis.

I haven't yet found a template for the plugin's composer.json, but adding WPCS + PHPCS + PHPCompatibility + DealerDirect/phpcodesniffer-composer-installer to a composer.json would make PHPCS runnable from local, without Travis.

danielbachhuber commented 6 years ago

I can't think of any issues with adding a composer.json for wp scaffold plugin.

However, the original reason for installing WPCS as a global install was to avoid overwriting an existing composer.json in wp scaffold plugin-tests. As such, an implementation for wp scaffold plugin-tests that wanted to create a composer.json would also need to programmatically modify an existing composer.json.

jrfnl commented 6 years ago

As noted in #161, I'd strongly advise to use the phpcompatibility/phpcompatibility-wp dependency instead of PHPCompatibility.

NicktheGeek commented 6 years ago

I was thinking about this and I agree that editing an existing composer file is a potential issue. However, that could be a potential issue regardless. Someone might have an existing project they want to add tests to.

So I thought instead of reinventing the wheel in order to update the composer.json file, can/should the wp scaffold plugin file check to see if the composer file exists and if it does use shell_exec() or something similar to run the composer commands to add the packages to the project?