-
Notifications
You must be signed in to change notification settings - Fork 86
Consider supporting trunk/nightly WordPress version #1072
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
39013c2
test nightly versions
bcotrim cc3508a
remove isNightly prop
bcotrim 14a18d5
add support for nighthly versions
bcotrim 3212878
pr feedback adjustments
bcotrim c79504e
remove un-used test file
bcotrim c181aa8
add missing files
bcotrim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import { | ||
| getWordPressVersionUrl, | ||
| isWordPressDevVersion, | ||
| isWordPressBetaVersion, | ||
| } from '../wordpress-version-utils'; | ||
|
|
||
| describe( 'isWordPressDevVersion', () => { | ||
| test( 'should identify WordPress development versions', () => { | ||
| expect( isWordPressDevVersion( '6.8-beta2-59979' ) ).toBe( true ); | ||
| expect( isWordPressDevVersion( '6.8-59979' ) ).toBe( true ); | ||
| expect( isWordPressDevVersion( '6.8.3-59979' ) ).toBe( true ); | ||
| expect( isWordPressDevVersion( '6.8-alpha1-12345' ) ).toBe( true ); | ||
| expect( isWordPressDevVersion( '6.8-RC1-59979' ) ).toBe( true ); | ||
| } ); | ||
|
|
||
| test( 'should return false for regular WordPress versions', () => { | ||
| expect( isWordPressDevVersion( '6.2' ) ).toBe( false ); | ||
| expect( isWordPressDevVersion( '6.2.1' ) ).toBe( false ); | ||
| expect( isWordPressDevVersion( '6.3-beta1' ) ).toBe( false ); | ||
| expect( isWordPressDevVersion( '6.3-RC1' ) ).toBe( false ); | ||
| } ); | ||
|
|
||
| test( 'should return false for invalid or empty versions', () => { | ||
| expect( isWordPressDevVersion( '' ) ).toBe( false ); | ||
| expect( isWordPressDevVersion( 'latest' ) ).toBe( false ); | ||
| expect( isWordPressDevVersion( '6.8-beta2' ) ).toBe( false ); | ||
| expect( isWordPressDevVersion( '6.8-ABCD' ) ).toBe( false ); | ||
| expect( isWordPressDevVersion( 'not-a-version' ) ).toBe( false ); | ||
| } ); | ||
| } ); | ||
|
|
||
| describe( 'isWordPressBetaVersion', () => { | ||
| test( 'should identify beta and RC versions', () => { | ||
| // Beta versions | ||
| expect( isWordPressBetaVersion( '6.3-beta1' ) ).toBe( true ); | ||
| expect( isWordPressBetaVersion( '6.3-beta2' ) ).toBe( true ); | ||
| expect( isWordPressBetaVersion( '6.3.1-beta1' ) ).toBe( true ); | ||
|
|
||
| // RC versions | ||
| expect( isWordPressBetaVersion( '6.3-RC1' ) ).toBe( true ); | ||
| expect( isWordPressBetaVersion( '6.3-RC2' ) ).toBe( true ); | ||
| expect( isWordPressBetaVersion( '6.3.1-RC1' ) ).toBe( true ); | ||
|
|
||
| // Dev versions with beta/RC | ||
| expect( isWordPressBetaVersion( '6.8-beta2-59979' ) ).toBe( true ); | ||
| expect( isWordPressBetaVersion( '6.8-RC1-59979' ) ).toBe( true ); | ||
| } ); | ||
|
|
||
| test( 'should return false for non-beta/RC versions', () => { | ||
| // Regular versions | ||
| expect( isWordPressBetaVersion( '6.2' ) ).toBe( false ); | ||
| expect( isWordPressBetaVersion( '6.2.1' ) ).toBe( false ); | ||
|
|
||
| // Alpha and other dev versions | ||
| expect( isWordPressBetaVersion( '6.8-alpha1-12345' ) ).toBe( false ); | ||
| expect( isWordPressBetaVersion( '6.8-59979' ) ).toBe( false ); | ||
| } ); | ||
|
|
||
| test( 'should return false for invalid or empty versions', () => { | ||
| expect( isWordPressBetaVersion( '' ) ).toBe( false ); | ||
| expect( isWordPressBetaVersion( 'latest' ) ).toBe( false ); | ||
| expect( isWordPressBetaVersion( '6.8-ABCD' ) ).toBe( false ); | ||
| expect( isWordPressBetaVersion( 'not-a-version' ) ).toBe( false ); | ||
| } ); | ||
| } ); | ||
|
|
||
| describe( 'getWordPressVersionUrl', () => { | ||
| test( 'should return nightly build URL for development versions', () => { | ||
| expect( getWordPressVersionUrl( '6.8-59979' ) ).toBe( | ||
| 'https://wordpress.org/nightly-builds/wordpress-latest.zip' | ||
| ); | ||
| expect( getWordPressVersionUrl( '6.9-12345' ) ).toBe( | ||
| 'https://wordpress.org/nightly-builds/wordpress-latest.zip' | ||
| ); | ||
| expect( getWordPressVersionUrl( '6.8-beta3-600046' ) ).toBe( | ||
| 'https://wordpress.org/nightly-builds/wordpress-latest.zip' | ||
| ); | ||
| expect( getWordPressVersionUrl( '6.8-RC1-59979' ) ).toBe( | ||
| 'https://wordpress.org/nightly-builds/wordpress-latest.zip' | ||
| ); | ||
| } ); | ||
|
|
||
| test( 'should return correct URL for normal versions', () => { | ||
| expect( getWordPressVersionUrl( '6.2' ) ).toBe( 'https://wordpress.org/wordpress-6.2.zip' ); | ||
| expect( getWordPressVersionUrl( '6.2.1' ) ).toBe( 'https://wordpress.org/wordpress-6.2.1.zip' ); | ||
| expect( getWordPressVersionUrl( '6.3-beta1' ) ).toBe( | ||
| 'https://wordpress.org/wordpress-6.3-beta1.zip' | ||
| ); | ||
| } ); | ||
|
|
||
| test( 'should throw error for invalid versions', () => { | ||
| expect( () => getWordPressVersionUrl( 'invalid' ) ).toThrow( | ||
| 'Unrecognized WordPress version. Please use "latest" or numeric versions such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"' | ||
| ); | ||
| expect( () => getWordPressVersionUrl( '6.invalid' ) ).toThrow(); | ||
| expect( () => getWordPressVersionUrl( '' ) ).toThrow(); | ||
| } ); | ||
|
|
||
| test( 'should use default version when none provided', () => { | ||
| expect( () => getWordPressVersionUrl() ).not.toThrow(); | ||
| } ); | ||
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { DEFAULT_WORDPRESS_VERSION } from 'vendor/wp-now/src/constants'; | ||
| import { isValidWordPressVersion } from 'vendor/wp-now/src/wp-playground-wordpress/is-valid-wordpress-version'; | ||
|
|
||
| export function isWordPressDevVersion( version: string ): boolean { | ||
| // Match nightly build patterns that end with a build number | ||
| // Examples: 6.8-alpha1-12345, 6.8-beta2-59979, 6.8-dev-12345, 6.8-59979 | ||
| return /^\d+\.\d+(?:\.\d+)?(?:-[a-zA-Z0-9]+)*-\d+$/.test( version ); | ||
| } | ||
|
|
||
| export function isWordPressBetaVersion( version: string ): boolean { | ||
| return version.includes( 'beta' ) || version.includes( 'RC' ); | ||
| } | ||
|
|
||
| export function getWordPressVersionUrl( version = DEFAULT_WORDPRESS_VERSION ) { | ||
| if ( isWordPressDevVersion( version ) ) { | ||
| return 'https://wordpress.org/nightly-builds/wordpress-latest.zip'; | ||
| } | ||
|
|
||
| if ( ! isValidWordPressVersion( version ) ) { | ||
| throw new Error( | ||
| 'Unrecognized WordPress version. Please use "latest" or numeric versions such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"' | ||
| ); | ||
| } | ||
| return `https://wordpress.org/wordpress-${ version }.zip`; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are we sure the nightly version follows this pattern even when there are no betas?
I think we shouldn't mix functions that check Studio versions and WordPress versions.
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.
Nice one!
I updated the check to allow for more scenarios, let me know what you think.
Also moved all WordPress version functions to a new lib file.
Uh oh!
There was an error while loading. Please reload this page.
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.
@bcotrim , I don't see this change. Did you already push the commit?
BTW, the image of Edit Site in the description doesn't belong to the modal.
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.
Sorry I sent the comment before I wanted to.
It should be good to review now.