Turn WordPress plugin zip files into git repositories, so that composer version constraint could work properly.
- Goal
- Requirements
- Installation
- Usage
- Examples
- FAQ
- How to install the
composify
-ed plugin viacomposer
? - Can I change default flag values via environment variables?
- Can I install
composify
instead of using$ npx
? - How about plugins on wordpress.org?
- Is it a must to use
composify
with Bedrock? - It looks awesome. Where can I find some more goodies like this?
- This isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?
- How to install the
- Feedback
- Security
- Change log
- Credits
- License
Since plugin auothers do ususally provide custom composer repositories (e.g: Private Packagist, satis), installing premium WordPress plugins via composer
is not easy.
Lots of tutorials teach you: open composer.json
and add the following within the repositories
array:
// https://kinsta.com/blog/bedrock-trellis/
{
"type": "package",
"package": {
"name": "kinsta/kinsta-mu-plugins",
"type": "wordpress-muplugin",
"version": "2.0.15",
"dist": {
"url": "https://kinsta.com/kinsta-tools/kinsta-mu-plugins.zip",
"type": "zip"
}
}
}
The problems:
- if
package.dist.url
is version-locked, therepositories
array has to be updated whenever new plugin version is released - if
package.dist.url
is not version-locked,$ composer install
is not deterministic (even withcomposer.lock
)package.dist.url
always point to the latest versionpackage.version
becomes meaningless because the downloaded zip couble be a newer version- running
$ composer install
(without changing anything) could break the site becuase a newer plugin version is installed - when composer caching invoked, there is no way to know which plugin version will be installed
The solution / what composify
does:
- download the plugin zip file
- unzip it
- generate
composer.json
- commit plugins files and
composer.json
$ git tag
$ git push --follow-tags
- NodeJS v10.0.0 or later
$ npx @itinerisltd/composify
just work! No installation required.
$ npx @itinerisltd/composify --help
describe the command here
USAGE
$ composify
OPTIONS
-d, --directory=directory directory name after unzip [example: kinsta-mu-plugins]
-f, --file=file main plugin file which containing the plugin header comment
[example: kinsta-mu-plugins.php]
-h, --help show CLI help
-n, --name=name (required) package name [example: kinsta-mu-plugins]
-o, --vendor=vendor (required) vender / organization name [example: itinerisltd]
-r, --repo=repo url to the latest zip file [example:
https://github.com/ItinerisLtd/kinsta-mu-plugins.git]
-t, --type=wordpress-plugin|wordpress-muplugin (required) [default: wordpress-plugin] package type
-u, --unzipDir=unzipDir unzip file to this directory, only use when default is breking
[example: kinsta-mu-plugins]
-v, --version show CLI version
-z, --zip=zip (required) url to the latest zip file [example:
https://kinsta.com/kinsta-tools/kinsta-mu-plugins.zip]
$ npx @itinerisltd/composify --vendor=itinerisltd --name=gravityforms --zip=<the-signed-s3-url>
Note the flags:
$ wget <the-signed-s3-url>
$ tree .
.
└── gravityforms_x.y.z.zip
$ unzip -o ./gravityforms_2.4.5.zip
$ tree .
.
├── gravityforms <-- `--directory`
│ ├── gravityforms.php <-- `--file`
│ ├── xxx
│ └── yyy.php
└── gravityforms_x.y.z.zip
--directory
is omitted because it defaults to${name}
, i.e:gravityforms
--file
is omitted because it defaults to${name}.php
, i.e:gravityforms.php
--repo
is omitted because it defaults tohttps://github.com/${vendor}/${name}.git
--unzipDir
is omitted because main plugin file is inside--directory
$ npx @itinerisltd/composify --vendor=itinerisltd --name=advanced-custom-fields-pro --file=acf.php --zip=https://connect.advancedcustomfields.com/xxx
Note the flags:
$ wget https://connect.advancedcustomfields.com/xxx
$ tree .
.
└── advanced-custom-fields-pro.zip
$ unzip -o ./advanced-custom-fields-pro.zip
$ tree .
.
├── advanced-custom-fields-pro <-- `--directory`
│ ├── acf.php <-- `--file`
│ ├── readme.txt
│ └── xxx
└── advanced-custom-fields-pro.zip
--file
is set toacf.php
$ npx @itinerisltd/composify --vendor=itinerisltd --name=kinsta-mu-plugins --zip=https://kinsta.com/kinsta-tools/kinsta-mu-plugins.zip --unzipDir=kinsta-mu-plugins --type=wordpress-muplugin
Note the flags:
$ wget https://kinsta.com/kinsta-tools/kinsta-mu-plugins.zip
$ tree .
.
└── kinsta-mu-plugins.zip
$ unzip -o ./kinsta-mu-plugins.zip
$ tree .
.
├── kinsta-mu-plugins
│ ├── xxx
│ └── yyy
├── kinsta-mu-plugins.php <-- `--file`
└── kinsta-mu-plugins.zip
--unzipDir
is set (ususally same as--name
or--directory
) because the unzipped content is not contained inside a--directory
Open composer.json
and add your git remote into repositories
:
{
"repositories": [
{
"type": "git",
"url": "https://github.com/<vendor>/<name>"
}
]
}
$ composer require <vendor>/<name>
See: https://getcomposer.org/doc/05-repositories.md#vcs
Yes.
These 2 commands are equivalent:
$ COMPOSIFY_VENDOR=itinerisltd COMPOSIFY_NAME=gravityforms COMPOSIFY_ZIP=<the-signed-s3-url> npx @itinerisltd/composify
$ npx @itinerisltd/composify --vendor=itinerisltd --name=gravityforms --zip=<the-signed-s3-url>
Yes. However, you are responsible for updating it.
# yarn or npm doesn't matter
$ yarn global add @itinerisltd/composify
$ composify --vendor=itinerisltd --name=gravityforms --zip=<the-signed-s3-url>
Use WordPress Packagist instead.
No.
Although we prefer and sponsor Bedrock at Itineris, you can composify
any plugin zip files into git repositories, and install them via composer.
Bedrock alternatives:
- Articles on Itineris' blog
- More projects on Itineris' GitHub profile
- Follow @itineris_ltd and @TangRufus on Twitter
- Hire Itineris to build your next awesome site
Thanks! Glad you like it. It's important to make my boss know somebody is using this project. Instead of giving reviews on wp.org, consider:
- tweet something good with mentioning @itineris_ltd and @TangRufus
- star this Github repo
- watch this Github repo
- write blog posts
- submit pull requests
- hire Itineris
Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CHANGELOG for more information on what has changed recently.
composify is a Itineris Limited project created by Tang Rufus.
Full list of contributors can be found here.
composify is released under the MIT License.