-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tools to import/export content #3354
Conversation
This change adds tools to import/export content from the local wp-env instance. Content can be pulled from your sandbox, themedemo.wordpress.com or from the theme-unit-test repository The sandbox.sh script was changed to power the "export" (from sandbox or themedemo) functionality. The .wp-env.json was changed to supply the content from theme-unit-test repository, map local folders for import/export of the rest of the resources and to provide the import plugin by default. npm scripts have been added to package.json in order to drive the commands. Documentation in readme has been updated to reflect the additional capabilities.
This is great! Thank you for the play by play testing instructions, it was a pleasure to follow along. This is going to help standardize and ease our testing processes significantly, thank you! Here are some notes from my testing. ✅
✅
✅ ✅
✅
❌
✅
|
@@ -141,7 +141,30 @@ How do you wish to proceed? [1]" | |||
cmd="rsync -av --no-p --no-times --exclude-from='.sandbox-ignore' --exclude=$ignore_string ./ $SANDBOX_USER@$SANDBOX_LOCATION:$SANDBOX_PUBLIC_THEMES_FOLDER/" | |||
eval $cmd | |||
|
|||
elif [[ $1 == "export" ]]; then | |||
# Export the site content from your sandbox to a local file | |||
export_command='ssh $SANDBOX_USER@$SANDBOX_LOCATION "mkdir /home/wpcom/export ; rm /home/wpcom/export/* ; /home/wpcom/public_html/bin/wp export --dir=/home/wpcom/export"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this command assumes I have some exported content in /home/wpcom/export already
? Is there a way I could specify a specific site of mine to export from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that command will create the file in the /home/wpcom/export folder and then copy it locally.
It's a pretty hacky way to do it I think but I couldn't quite get things to work in another way. And Bash always just seems like a giant roll of duct tape to me anyway...
It would be a simple change to target a particular site defined in the command execution, yea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truth be told I have NO idea where there's a mkdir
followed by an immediate rm
so that's probably something that should change (even if it doesn't not work)
|
||
elif [[ $1 == "export-theam" ]]; then | ||
# Export the site content from theamdemo to a local file | ||
export_command='ssh $SANDBOX_USER@$SANDBOX_LOCATION "mkdir /home/wpcom/export ; rm /home/wpcom/export/* ; /home/wpcom/public_html/bin/wp export --dir=/home/wpcom/export --url=theamdemo.wordpress.com"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should probably just change to use whatever URL you pass in like:
./sandbox.sh export theamdemo.wordpress.com
instead of
./sandbox.sh export-theam
allowing for
./sandbox.sh export peanutbutterbatter.wordpress.com
As mentioned in Slack, I think this really belongs outside the themes repo as it's so specific to a8c. IMO a8c-wp-env would be a good home for it. |
Closing this and adding to a8c-wp-env instead via: https://github.com/Automattic/a8c-wp-env/pull/81 |
Changes proposed in this Pull Request:
This change adds tools to import/export content from the local wp-env
instance.
Content can be pulled from your sandbox, themedemo.wordpress.com or from
the theme-unit-test repository.
The sandbox.sh script was changed to power the "export" (from sandbox or
themedemo) functionality.
The .wp-env.json was changed to supply the content from theme-unit-test
repository, map local folders for import/export of the rest of the
resources and to provide the import plugin.
npm scripts have been added to package.json in order to drive the
commands.
Documentation in readme has been updated to reflect the additional
capabilities.
Testing
Theam and Sandbox content export
From the root of the project run
npm run wp-env:export:theam
(or./sandbox.sh export-theam
) and note the file copied to ./export/theamdemo.wordpress.xml reflects the content on theamdemo.wordpress.comFrom the root of the project run
npm run wp-env:export:sandbox
(or./sandbox.sh export
) and note the file copied to ./export/sandbox.wordpress.xml reflects the content on your sandboxNOTE: The following will remove & replace all of the content in the targeted instance of WordPress. Make sure you don't mind it going away.
Make sure there are no instances of wp-env running. (Checking Docker Dashboard is helpful for this just to make sure...)
Spin up a new wp-env instance from the root of the project folder:
npm run wp-env
and ensure that it's running properly: http://localhost:8888Run
npm run wp-env:empty
and ensure that there is no content to be found on our local wp-env instanceRun
npm run wp-env:import:sandbox
and ensure that the content on your local wp-env instance reflects the same content found on your sandbox. (Ensure you have downloaded the ./export/sandbox.wordpress.xml file from above instructions first.)Run
npm run wp-env:empty
again to clean our your local environment and thennpm run wp-env:import:theam
and ensure that the content on your local wp-env instance reflects the same content found on theamdemo.wordpress.com (Ensure you have downloaded the ./export/theamdemo.wordpress.xml file from above instructions first.)Run
npm run wp-env:empty
again to clean our your local environment and thennpm run wp-env:import:unittest
and ensure that the content on your local wp-env instance reflects the content from the theme-unit-test repository. (For this one you don't have to download anything first, it should be made available due to the mappings configuration in .wp-env.json. However that is dependent on this change which might not be available via npm yet so ymmv.)Run
npm run wp-env:export:local
and ensure that the file./export/local.wordpress.xml
reflects the same XML content found in the theme-unit-test repository (since that's the content that you last imported if you're playing along in order).Lastly run
npm run wp-env:cleanslate
. Your local content will be wiped, the content from theamdemo.wordpress.com will be downloaded to your local./export
folder and then imported into your wp-env instance.