WordPress / playground-tools

GNU General Public License v2.0
127 stars 38 forks source link

playground.wordpress.net: Make it easier to boot playground from a Github repository #314

Open akirk opened 2 weeks ago

akirk commented 2 weeks ago

After a conversation with @ndiego, I think we could make it much easier to load a theme, plugin, or whole WordPress site into playground.wordpress.net:

or if we could even do auto-detection (?), just

As a bonus, it should setup the Github exporter so that it is already ready to submit a PR based on your changes.

@ndiego shared this URL with me to achieve the same already today, we just need to simplify it, since it's both impossible to remember, and needs quite a bit of setup to make it work.

https://playground.wordpress.net/?
gh-ensure-auth=yes
&ghexport-repo-url=https://github.com/ndiego/nautilus
&ghexport-content-type=theme
&ghexport-theme=nautilus
&ghexport-commit-message=Nautilus+update
&ghexport-playground-root=/wordpress/wp-content/themes/nautilus
&ghexport-pr-action=create
&ghexport-allow-include-zip=no
&blueprint-url=https://raw.githubusercontent.com/ndiego/nautilus/main/_playground/blueprint.json

I believe we can infer all of those values from just the Github URL and for other dependencies, you put a blueprint.json in the root of the directory (Compare with Nick's https://raw.githubusercontent.com/ndiego/nautilus/main/_playground/blueprint.json)

For now, we'd need to transparently use github-proxy.com and remove it when/if Github decides to open up CORS.

akirk commented 1 week ago

Noting that an important step in the above is that we'd automatically map the Github contents into the playground. Because of the name in the Github zipfile, it needs some renaming:

        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "url",
                "url": "https://github-proxy.com/proxy/?repo=ndiego/nautilus"
            }
        },
        {
            "step": "mv",
            "fromPath": "/wordpress/wp-content/themes/nautilus-main",
            "toPath": "/wordpress/wp-content/themes/nautilus"
        },
bgrgicak commented 1 week ago

I'm not sure about auto-detecting, Playground usually avoids guessing. WP-now tries to auto-detect what to do and it's not the best experience sometimes while it's easy to define this using a blueprint.

        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "url",
                "url": "https://github-proxy.com/proxy/?repo=ndiego/nautilus"
            }
        },
        {
            "step": "mv",
            "fromPath": "/wordpress/wp-content/themes/nautilus-main",
            "toPath": "/wordpress/wp-content/themes/nautilus"
        },

Looking at this example, we could automatically export the theme/plugin to the correct folder instead of REPO-BRANCH. The only issue is that some blueprints currently depend on this behavior.

AmnestyAM commented 6 hours ago

I am also finding it hard to load a custom theme. https://github.com/amnestywebsite/humanity-blueprint

Amongst lots of uneducated trying I have tried the following.

using the raw githubusercontent domain method

        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "url",
                "url": "https://raw.githubusercontent.com/amnestywebsite/humanity-blueprint/main/humanity-theme.zip"
            }
        },

using the GitHub proxy method

        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "url",
                "url": "https://github-proxy.com/proxy/?repo=https://github.com/amnestywebsite/humanity-theme/"
            }
        },
        {
            "step": "mv",
            "fromPath": "/wordpress/wp-content/themes/humanity-theme-main",
            "toPath": "/wordpress/wp-content/themes/humanity-theme"
        },

I have tried via WP CLI

    {
      "step": "wp-cli",
      "command": "wp theme install https://raw.githubusercontent.com/amnestywebsite/humanity-blueprint/main/humanity-theme.zip"
    }

this told me to install wp package install wp-cli/restful which couldn't not be installed

The "https://wp-cli.org/package-index/packages.json" file could not be downloaded: allow_url_fopen must be enabled in php.ini

I also opened a ticket here https://github.com/WordPress/blueprints/issues/58 which I think I will close as I probably can just follow this issue.

If anyone finds a solution that works for this https://github.com/amnestywebsite/humanity-blueprint I would love to hear it, until then I will wait for this enhancement, thanks all :-)