-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Use git for wp-env
's default WordPress version
#42826
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
909f7a6
Add function to retreive the latest stable WordPress version
noahtallen 1d6f7e3
Change the default core source to the latest stable tag in the WordPr…
noahtallen 64fb3eb
Update unit tests
noahtallen 111f620
Update readme and documentation
noahtallen f9a0a4d
Safer handling when getting latest wp version
noahtallen b45af9c
Use got instead of https
noahtallen 7b4d77d
Update changelog to mention bug fix
noahtallen df4fc53
Move fix to fixes header
noahtallen 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 contains 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 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 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ const readRawConfigFile = require( './read-raw-config-file' ); | |
const parseConfig = require( './parse-config' ); | ||
const { includeTestsPath, parseSourceString } = parseConfig; | ||
const md5 = require( '../md5' ); | ||
const { getLatestWordPressVersion } = require( '../wordpress' ); | ||
|
||
/** | ||
* wp-env configuration. | ||
|
@@ -33,7 +34,7 @@ const md5 = require( '../md5' ); | |
* Base-level config for any particular environment. (development/tests/etc) | ||
* | ||
* @typedef WPServiceConfig | ||
* @property {?WPSource} coreSource The WordPress installation to load in the environment. | ||
* @property {WPSource} coreSource The WordPress installation to load in the environment. | ||
* @property {WPSource[]} pluginSources Plugins to load in the environment. | ||
* @property {WPSource[]} themeSources Themes to load in the environment. | ||
* @property {number} port The port to use. | ||
|
@@ -68,9 +69,37 @@ module.exports = async function readConfig( configPath ) { | |
md5( configPath ) | ||
); | ||
|
||
// The specified base configuration from .wp-env.json or from the local | ||
// source type which was automatically detected. | ||
const baseConfig = | ||
( await readRawConfigFile( '.wp-env.json', configPath ) ) || | ||
( await getDefaultBaseConfig( configPath ) ); | ||
|
||
// Overriden .wp-env.json on a per-user case. | ||
const overrideConfig = | ||
( await readRawConfigFile( | ||
'.wp-env.override.json', | ||
configPath.replace( /\.wp-env\.json$/, '.wp-env.override.json' ) | ||
) ) || {}; | ||
|
||
const detectedLocalConfig = | ||
Object.keys( { ...baseConfig, ...overrideConfig } ).length > 0; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lines above were just moved from lower in the file so that the information is available for the following if statement |
||
// If there is no local WordPress version, use the latest stable version from GitHub. | ||
let coreRef; | ||
if ( ! overrideConfig.core && ! baseConfig.core ) { | ||
const wpVersion = await getLatestWordPressVersion(); | ||
if ( ! wpVersion ) { | ||
throw new ValidationError( | ||
'Could not find the latest WordPress version. There may be a network issue.' | ||
); | ||
} | ||
coreRef = `WordPress/WordPress#${ wpVersion }`; | ||
} | ||
|
||
// Default configuration which is overridden by .wp-env.json files. | ||
const defaultConfiguration = { | ||
core: null, | ||
core: coreRef, | ||
phpVersion: null, | ||
plugins: [], | ||
themes: [], | ||
|
@@ -96,22 +125,6 @@ module.exports = async function readConfig( configPath ) { | |
}, | ||
}; | ||
|
||
// The specified base configuration from .wp-env.json or from the local | ||
// source type which was automatically detected. | ||
const baseConfig = | ||
( await readRawConfigFile( '.wp-env.json', configPath ) ) || | ||
( await getDefaultBaseConfig( configPath ) ); | ||
|
||
// Overriden .wp-env.json on a per-user case. | ||
const overrideConfig = | ||
( await readRawConfigFile( | ||
'.wp-env.override.json', | ||
configPath.replace( /\.wp-env\.json$/, '.wp-env.override.json' ) | ||
) ) || {}; | ||
|
||
const detectedLocalConfig = | ||
Object.keys( { ...baseConfig, ...overrideConfig } ).length > 0; | ||
|
||
// A quick validation before merging on a service by service level allows us | ||
// to check the root configuration options and provide more helpful errors. | ||
validateConfig( | ||
|
This file contains 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 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 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
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.
This is never
null
now that we default to a git source when the user doesn't provide one. As a result, there is probably more code to cleanup, but everything should work correctly in the meantime.