Automattic / newspack-custom-content-migrator

Custom migration tasks for launching and migrating Newspack sites on Atomic
5 stars 5 forks source link

Settings Migrator: Allow file-less import/export #293

Closed philipjohn closed 3 weeks ago

philipjohn commented 1 year ago

On some hosts it's not possible to write the the filesystem (e.g. VIP). As such the import & export commands fail because they cannot write to the filesystem.

This change ensures the commands work as expected with a given directory but also accept STDIN for importing settings and printing the JSON for exports.

For example, the settings can be exported with

$ wp newspack-content-migrator export-pages-settings --output-dir=settings
Exporting default pages settings...
Writing to file settings/newspack-settings-pages.json
Success: Done.

OR

$ wp newspack-content-migrator export-pages-settings
Exporting default pages settings...
{"show_on_front":false,"page_on_front":"0","page_for_posts":"0","newspack_donation_page_id":false}
Success: Done.

Similarly, importing settings can be done with

$ wp newspack-content-migrator import-pages-settings --input-dir=settings
Importing default pages settings from settings/newspack-settings-pages.json...
Success: Done.

OR

$ wp newspack-content-migrator import-pages-settings < settings/newspack-settings-pages.json 
Importing default pages settings from STDIN...
Success: Done.

OR

$ cat settings/newspack-settings-pages.json | wp newspack-content-migrator import-pages-settings
Importing default pages settings from STDIN...
Success: Done.
iuravic commented 3 weeks ago

Closing as out of date.