@wordpress/env 5.1.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -2
- package/lib/config/config.js +14 -30
- package/lib/config/parse-config.js +18 -2
- package/lib/wordpress.js +7 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 5.1.1 (2022-08-16)
|
|
6
|
+
|
|
7
|
+
### Bug Fix
|
|
8
|
+
- Fix a crash when "core" was set to `null` in a `.wp-env.json` file. We now use the latest stable WordPress version in that case. This also restores the previous behavior of `"core": null` in `.wp-env.override.json`, which was to use the latest stable WordPress version.
|
|
9
|
+
|
|
5
10
|
## 5.1.0 (2022-08-10)
|
|
6
11
|
|
|
7
12
|
### Enhancement
|
|
8
|
-
-
|
|
13
|
+
- Previously, wp-env used the WordPress version provided by Docker in the WordPress image for installations which don't specify a WordPress version. Now, wp-env will find the latest stable version on WordPress.org and check out the https://github.com/WordPress/WordPress repository at the tag matching that version. In most cases, this will match what Docker provides. The benefit is that wp-env (and WordPress.org) now controls the default WordPress version rather than Docker.
|
|
9
14
|
|
|
10
15
|
### Bug Fix
|
|
11
|
-
-
|
|
16
|
+
- Downloading a default WordPress version also resolves a bug where the wrong WordPress test files were used if no core source was specified in wp-env.json. The current trunk test files were downloaded rather than the stable version. Now, the test files will match the default stable version.
|
|
12
17
|
|
|
13
18
|
## 5.0.0 (2022-07-27)
|
|
14
19
|
|
package/lib/config/config.js
CHANGED
|
@@ -15,7 +15,6 @@ const readRawConfigFile = require( './read-raw-config-file' );
|
|
|
15
15
|
const parseConfig = require( './parse-config' );
|
|
16
16
|
const { includeTestsPath, parseSourceString } = parseConfig;
|
|
17
17
|
const md5 = require( '../md5' );
|
|
18
|
-
const { getLatestWordPressVersion } = require( '../wordpress' );
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* wp-env configuration.
|
|
@@ -85,21 +84,9 @@ module.exports = async function readConfig( configPath ) {
|
|
|
85
84
|
const detectedLocalConfig =
|
|
86
85
|
Object.keys( { ...baseConfig, ...overrideConfig } ).length > 0;
|
|
87
86
|
|
|
88
|
-
// If there is no local WordPress version, use the latest stable version from GitHub.
|
|
89
|
-
let coreRef;
|
|
90
|
-
if ( ! overrideConfig.core && ! baseConfig.core ) {
|
|
91
|
-
const wpVersion = await getLatestWordPressVersion();
|
|
92
|
-
if ( ! wpVersion ) {
|
|
93
|
-
throw new ValidationError(
|
|
94
|
-
'Could not find the latest WordPress version. There may be a network issue.'
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
coreRef = `WordPress/WordPress#${ wpVersion }`;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
87
|
// Default configuration which is overridden by .wp-env.json files.
|
|
101
88
|
const defaultConfiguration = {
|
|
102
|
-
core:
|
|
89
|
+
core: null, // Indicates that the latest stable version should ultimately be used.
|
|
103
90
|
phpVersion: null,
|
|
104
91
|
plugins: [],
|
|
105
92
|
themes: [],
|
|
@@ -155,23 +142,21 @@ module.exports = async function readConfig( configPath ) {
|
|
|
155
142
|
|
|
156
143
|
// Merge each of the specified environment-level overrides.
|
|
157
144
|
const allPorts = new Set(); // Keep track of unique ports for validation.
|
|
158
|
-
const env =
|
|
159
|
-
|
|
145
|
+
const env = {};
|
|
146
|
+
for ( const envName of allEnvs ) {
|
|
147
|
+
env[ envName ] = await parseConfig(
|
|
160
148
|
validateConfig(
|
|
161
149
|
mergeWpServiceConfigs( [
|
|
162
|
-
...getEnvConfig( defaultConfiguration,
|
|
163
|
-
...getEnvConfig( baseConfig,
|
|
164
|
-
...getEnvConfig( overrideConfig,
|
|
150
|
+
...getEnvConfig( defaultConfiguration, envName ),
|
|
151
|
+
...getEnvConfig( baseConfig, envName ),
|
|
152
|
+
...getEnvConfig( overrideConfig, envName ),
|
|
165
153
|
] ),
|
|
166
|
-
|
|
154
|
+
envName
|
|
167
155
|
),
|
|
168
|
-
{
|
|
169
|
-
workDirectoryPath,
|
|
170
|
-
}
|
|
156
|
+
{ workDirectoryPath }
|
|
171
157
|
);
|
|
172
|
-
allPorts.add(
|
|
173
|
-
|
|
174
|
-
}, {} );
|
|
158
|
+
allPorts.add( env[ envName ].port );
|
|
159
|
+
}
|
|
175
160
|
|
|
176
161
|
if ( allPorts.size !== allEnvs.length ) {
|
|
177
162
|
throw new ValidationError(
|
|
@@ -262,6 +247,7 @@ async function getDefaultBaseConfig( configPath ) {
|
|
|
262
247
|
* @return {WPConfig} configuration object with overrides applied.
|
|
263
248
|
*/
|
|
264
249
|
function withOverrides( config ) {
|
|
250
|
+
const workDirectoryPath = config.workDirectoryPath;
|
|
265
251
|
// Override port numbers with environment variables.
|
|
266
252
|
config.env.development.port =
|
|
267
253
|
getNumberFromEnvVariable( 'WP_ENV_PORT' ) ||
|
|
@@ -273,10 +259,8 @@ function withOverrides( config ) {
|
|
|
273
259
|
// Override WordPress core with environment variable.
|
|
274
260
|
if ( process.env.WP_ENV_CORE ) {
|
|
275
261
|
const coreSource = includeTestsPath(
|
|
276
|
-
parseSourceString( process.env.WP_ENV_CORE, {
|
|
277
|
-
|
|
278
|
-
} ),
|
|
279
|
-
{ workDirectoryPath: config.workDirectoryPath }
|
|
262
|
+
parseSourceString( process.env.WP_ENV_CORE, { workDirectoryPath } ),
|
|
263
|
+
{ workDirectoryPath }
|
|
280
264
|
);
|
|
281
265
|
config.env.development.coreSource = coreSource;
|
|
282
266
|
config.env.tests.coreSource = coreSource;
|
|
@@ -9,6 +9,7 @@ const os = require( 'os' );
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
const { ValidationError } = require( './validate-config' );
|
|
12
|
+
const { getLatestWordPressVersion } = require( '../wordpress' );
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {import('./config').WPServiceConfig} WPServiceConfig
|
|
@@ -32,12 +33,12 @@ const HOME_PATH_PREFIX = `~${ path.sep }`;
|
|
|
32
33
|
* @param {string} options.workDirectoryPath Path to the work directory located in ~/.wp-env.
|
|
33
34
|
* @return {WPServiceConfig} Parsed environment-level configuration.
|
|
34
35
|
*/
|
|
35
|
-
module.exports = function parseConfig( config, options ) {
|
|
36
|
+
module.exports = async function parseConfig( config, options ) {
|
|
36
37
|
return {
|
|
37
38
|
port: config.port,
|
|
38
39
|
phpVersion: config.phpVersion,
|
|
39
40
|
coreSource: includeTestsPath(
|
|
40
|
-
|
|
41
|
+
await parseCoreSource( config.core, options ),
|
|
41
42
|
options
|
|
42
43
|
),
|
|
43
44
|
pluginSources: config.plugins.map( ( sourceString ) =>
|
|
@@ -58,6 +59,21 @@ module.exports = function parseConfig( config, options ) {
|
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
61
|
|
|
62
|
+
async function parseCoreSource( coreSource, options ) {
|
|
63
|
+
// An empty source means we should use the latest version of WordPress.
|
|
64
|
+
if ( ! coreSource ) {
|
|
65
|
+
const wpVersion = await getLatestWordPressVersion();
|
|
66
|
+
if ( ! wpVersion ) {
|
|
67
|
+
throw new ValidationError(
|
|
68
|
+
'Could not find the latest WordPress version. There may be a network issue.'
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
coreSource = `WordPress/WordPress#${ wpVersion }`;
|
|
73
|
+
}
|
|
74
|
+
return parseSourceString( coreSource, options );
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
/**
|
|
62
78
|
* Parses a source string into a source object.
|
|
63
79
|
*
|
package/lib/wordpress.js
CHANGED
|
@@ -277,13 +277,20 @@ async function readWordPressVersion( coreSource, spinner, debug ) {
|
|
|
277
277
|
*
|
|
278
278
|
* @return {string} The latest stable version of WordPress, like "6.0.1"
|
|
279
279
|
*/
|
|
280
|
+
let CACHED_WP_VERSION;
|
|
280
281
|
async function getLatestWordPressVersion() {
|
|
282
|
+
// Avoid extra network requests.
|
|
283
|
+
if ( CACHED_WP_VERSION ) {
|
|
284
|
+
return CACHED_WP_VERSION;
|
|
285
|
+
}
|
|
286
|
+
|
|
281
287
|
const versions = await got(
|
|
282
288
|
'https://api.wordpress.org/core/stable-check/1.0/'
|
|
283
289
|
).json();
|
|
284
290
|
|
|
285
291
|
for ( const [ version, status ] of Object.entries( versions ) ) {
|
|
286
292
|
if ( status === 'latest' ) {
|
|
293
|
+
CACHED_WP_VERSION = version;
|
|
287
294
|
return version;
|
|
288
295
|
}
|
|
289
296
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/env",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "A zero-config, self contained local WordPress environment for development and testing.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"scripts": {
|
|
52
52
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "002058dceb89577290da6139aea3e99459fb2298"
|
|
55
55
|
}
|