Skip to content

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Sep 2, 2025

Motivation for the change, related issues

See #1487

Before After
Screen.Recording.2025-09-02.at.1.27.48.pm.mov
Screen.Recording.2025-09-02.at.1.27.27.pm.mov

Implementation details

A APIBasedFetchResource class is inserted between the Core{Plugin,Theme}Resource and FetchResource to allow the API to be fetched as an intermediate step.
The name property is added to the Core{Plugin,Theme}Reference to prevent the name being sourced from the ZIP.
The name property is passed through to other steps where possible.

This is not perfect, but it works and provides a basis for some other incremental improvements.

Testing Instructions (or ideally a Blueprint)

https://playground.wordpress.net/?plugin=woocommerce
http://127.0.0.1:5400/website-server/?plugin=woocommerce

@dd32 dd32 changed the title Add/api names Fetch the WordPress.org API to determine Theme/Plugin names. Sep 2, 2025
this.progress?.loadingListener ?? noop
);
if (response.status !== 200) {
throw new Error(`Could not fetch "${url}"`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

My only note – I wouldn't break the entire Blueprint execution just because we can't fetch the name. Otherwise this PR seems like a great addition – thank you @dd32!

Copy link
Collaborator

@adamziel adamziel Sep 2, 2025

Choose a reason for hiding this comment

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

Aha, this isn't just a name now. The api.wordpress.org call also provides the download_link. Will it ever be different from https://downloads.wordpress.org/theme|plugin/${zipName}?

Copy link
Member Author

@dd32 dd32 Sep 3, 2025

Choose a reason for hiding this comment

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

I thought about this after the fact.. Specifically because of closed plugins..

I was thinking of updating it to the previous as the fallback as well as the latest-stable for the ZIP.

The ZIP is unlikely to change location, but I figured since I had the data here, I might as well use it to avoid the 301 from latest-stable to the versioned link.

If dependencies are requested as in #2582 then the API failing to retrieve would be more of a show-stopper, but even then, just failing to install the dependencies is probably a better thing than playground halting.

@adamziel
Copy link
Collaborator

adamziel commented Sep 9, 2025

@JanJakes would you be able to shepherd this PR? I think it might be good to go but I'd still love to get your opinion.

@JanJakes
Copy link
Member

👍 I'll check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants