Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/playground/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const unzipFile = async (
$zip->close();
chmod($extractTo, 0777);
} else {
throw new Exception("Could not unzip file: " . $zip->getStatusString());
$fileSize = file_exists($zipPath) ? filesize($zipPath) : 'unknown';
throw new Exception("Could not unzip file. Error code: " . $res . ". File size: " . $fileSize . " bytes.");
}
}
unzip(${js.zipPath}, ${js.extractToPath}, ${js.overwriteFiles});
Expand Down
7 changes: 5 additions & 2 deletions packages/playground/wordpress/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ const memoizedFetch = createMemoizedFetch(fetch);
* @returns The resolved WordPress release URL and version string.
*/
export async function resolveWordPressRelease(versionQuery = 'latest') {
if (
if (versionQuery === null) {
versionQuery = 'latest';
} else if (
versionQuery.startsWith('https://') ||
versionQuery.startsWith('http://')
) {
Expand Down Expand Up @@ -692,7 +694,8 @@ export async function resolveWordPressRelease(versionQuery = 'latest') {
};
} else if (
versionQuery === 'latest' &&
!apiVersion.version.includes('beta')
!apiVersion.version.includes('beta') &&
!apiVersion.version.includes('RC')
) {
// The first non-beta item in the list is the latest version.
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const mockApiResponse = {
download: 'https://wordpress.org/wordpress-6.9-beta1.zip',
response: 'autoupdate',
},
{
version: '6.9-RC1',
download: 'https://wordpress.org/wordpress-6.9-RC1.zip',
response: 'autoupdate',
},
],
};

Expand Down Expand Up @@ -55,7 +60,7 @@ describe('resolveWordPressRelease', () => {
mockFetch.mockClear();
});

it('resolves latest to the first non-beta version', async () => {
it('resolves latest to the first non-beta or release candidate version', async () => {
const result = await resolveWordPressRelease('latest');
expect(result.version).toBe('6.8.3');
expect(result.releaseUrl).toBe(
Expand Down Expand Up @@ -161,4 +166,13 @@ describe('resolveWordPressRelease', () => {
expect(result.releaseUrl).toBe(customUrl);
expect(result.source).toBe('inferred');
});

it('resolves null version to the first non-beta or release candidate version', async () => {
const result = await resolveWordPressRelease(null as any);
expect(result.version).toBe('6.8.3');
expect(result.releaseUrl).toBe(
'https://wordpress.org/wordpress-6.8.3.zip'
);
expect(result.source).toBe('api');
});
});
Loading