Simply-Static / simply-static

Convert your WordPress site into a static one with the free WordPress static site generator plugin, Simply Static.
https://simplystatic.com
GNU General Public License v2.0
200 stars 49 forks source link

How to install `simply-static` using wp-cli? #260

Closed vadimkantorov closed 1 month ago

vadimkantorov commented 1 month ago

How to install simply-static using CLI / wp-cli?

For wp2static I did sth like the following, which seems excessive. What should be the corresponding command to install simply-static? e.g. could I somehow just do php ./wp-cli.phar plugin install https://downloads.wordpress.org/plugin/simply-static.3.1.9.zip --activate?

And maybe there would be a simpler command to build the plugin locally? (e.g. a single composer install command?)

Thanks!

mkdir -p ./wp-content/plugins/wp2static
curl -O -L https://github.com/elementor/wp2static/archive/refs/tags/7.2.tar.gz | tar -xzf - -C ./wp-content/plugins/wp2static --strip-components=1
cd ./wp-content/plugins/wp2static
curl -o composer.phar https://getcomposer.org/installer
php composer.phar install
php composer.phar update
php composer.phar build
php composer.phar install --quiet --no-dev --optimize-autoloader
cd  ../../../
php ./wp-cli.phar plugin activate wp2static
patrickposner commented 1 month ago

@vadimkantorov 100% correct:

./wp-cli.phar plugin install https://downloads.wordpress.org/plugin/simply-static.3.1.9.zip --activate is the way to go!

You won't even need to install the composer dependencies, as these are already included in the version hosted on w.org!

However, if you want to manage everything with composer instead, we also have our own package hosted on Packagist: https://packagist.org/packages/simplystatic/simply-static

vadimkantorov commented 1 month ago

And regarding a general composer workflow ^_^, what is the typical command sequence? update-install? I have a feeling that for wp2static above I'm a bit overdoing it...

(and maybe same question if I wanted to install simply-static using composer or from source)

patrickposner commented 1 month ago

Instead of doing:

curl -o composer.phar https://getcomposer.org/installer php composer.phar install php composer.phar update php composer.phar build php composer.phar install --quiet --no-dev --optimize-autoloader

You only need:

curl -o composer.phar https://getcomposer.org/installer php composer.phar install composer require simplystatic/simply-static

The require method of the CLI should handle the rest for you: https://getcomposer.org/doc/03-cli.md#require-r

Full example:

mkdir -p ./wp-content/plugins/simply-static cd ./wp-content/plugins/simply-static curl -o composer.phar https://getcomposer.org/installer php composer.phar install composer require simplystatic/simply-static cd ../../../ php ./wp-cli.phar plugin activate simply-static