Skip to content
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

[Website] GitHub export modal: Correctly compute the root path when exporting the entire site #2103

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

adamziel
Copy link
Collaborator

Defaults to / as a root path instead of /playground to fix an error in the full site exporting flow.

One of the previous PRs for the GitHub export modal enforced using /playground as the exported path when the target path in repo was missing. This effectively broke the export feature as the initial REST API requests to list the existing files under the specified repository path failed with error 404.

Furthermore, with all the data massaging done in the form, one of the steps first replaced "/" with "" and then filtered it out as an empty value. This PR ensures that "/" remains a fallback for the relative repo path.

Really, we could use some automated tests to confirm all the different use-cases for that modal continue to work. It's complicated with the OAuth procedure required. What we could do is either mock the responses or migrate to the isomorphic-git client and ditch the REST API dependency. Git protocol is so much faster than the REST API anyway.

Testing instructions

  1. Go to the GitHub export modal
  2. Select "custom paths" and export the /wordpress directory to / in the repo
  3. Give it a new, empty repo
  4. Start the export procedure
  5. Confirm a lot of network requests start. There should be no errors in red text in sight.

Possible closes #2084

cc @bgrgicak

…xporting the entire site

Defaults to `/` as a root path instead of `/playground` to fix an error
in the full site exporting flow.

One of the previous PRs for the GitHub export modal enforced using
`/playground` as the exported path when the target path in repo was
missing. This effectively broke the export feature as the initial
REST API requests to list the existing files under the specified
repository path failed with error 404.

Furthermore, with all the data massaging done in the form, one of the
steps first replaced `"/"` with `""` and then filtered it out as an
empty value. This PR ensures that `"/"` remains a fallback for the
relative repo path.

Really, we could use some automated tests to confirm all the different
use-cases for that modal continue to work. It's complicated with the
OAuth procedure required. What we could do is either mock the responses
or migrate to the isomorphic-git client and ditch the REST API
dependency. Git protocol is so much faster than the REST API anyway.

 ## Testing instructions

1. Go to the GitHub export modal
2. Select "custom paths" and export the `/wordpress` directory to `/` in
   the repo
3. Give it a new, empty repo
4. Start the export procedure
5. Confirm a lot of network requests start. There should be no errors in
   red text in sight.
@bgrgicak
Copy link
Collaborator

Setup GitHub client locally

  • Register a new OAuth app
  • Create a .env file in your local copy of the WordPress Playground repository
  • The client ID and secret of your GitHub app to .env
CLIENT_ID=YOUR_ID_VALUE
CLIENT_SECRET=YOUR_VALUE
  • Restart the Playground development server (npm run dev)

Screenshot 2024-12-19 at 08 05 47

Copy link
Collaborator

@bgrgicak bgrgicak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that / is the new default path and that the exporter starts POSTing blobs to GitHub.

I still have the trees API issue described in #2084, but that shouldn't block this PR.

@adamziel adamziel merged commit d84c326 into trunk Dec 19, 2024
10 checks passed
@adamziel adamziel deleted the github-export-fix branch December 19, 2024 08:51
@adamziel
Copy link
Collaborator Author

Really good client setup instructions @bgrgicak 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Aspect] Website [Feature] GitHub integration [Type] Bug An existing feature does not function as intended
Projects
Archived in project
2 participants