blob: 3f3e601db2287c677f1e7f03719a9a2da1dbd3fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* jshint node:true */
const { existsSync } = require( 'node:fs' );
const local_env_utils = {
/**
* Determines which Docker compose files are required to properly configure the local environment given the
* specified PHP version, database type, and database version.
*
* By default, only the standard docker-compose.yml file will be used.
*
* When PHP 7.2 or 7.3 is used in combination with MySQL 8.4, an override file will also be returned to ensure
* that the mysql_native_password plugin authentication plugin is on and available for use.
*
* @return {string[]} Compose files.
*/
get_compose_files: function() {
const composeFiles = [ 'docker-compose.yml' ];
if ( existsSync( 'docker-compose.override.yml' ) ) {
composeFiles.push( 'docker-compose.override.yml' );
}
if ( process.env.LOCAL_DB_TYPE !== 'mysql' ) {
return composeFiles;
}
if ( process.env.LOCAL_PHP !== '7.2-fpm' && process.env.LOCAL_PHP !== '7.3-fpm' ) {
return composeFiles;
}
// PHP 7.2/7.3 in combination with MySQL 8.4 requires additional configuration to function properly.
if ( process.env.LOCAL_DB_VERSION === '8.4' ) {
composeFiles.push( 'tools/local-env/old-php-mysql-84.override.yml' );
}
return composeFiles;
},
/**
* Determines the option to pass for proper authentication plugin configuration given the specified PHP version,
* database type, and database version.
*/
determine_auth_option: function() {
if ( process.env.LOCAL_DB_TYPE !== 'mysql' ) {
return;
}
if ( process.env.LOCAL_PHP !== '7.2-fpm' && process.env.LOCAL_PHP !== '7.3-fpm' ) {
return;
}
// MySQL 8.4 removed --default-authentication-plugin in favor of --authentication-policy.
if ( process.env.LOCAL_DB_VERSION === '8.4' ) {
process.env.LOCAL_DB_AUTH_OPTION = '--authentication-policy=mysql_native_password';
} else {
process.env.LOCAL_DB_AUTH_OPTION = '--default-authentication-plugin=mysql_native_password';
}
}
};
module.exports = local_env_utils;
|