44const fs = require ( 'fs' ) ;
55const _ = require ( 'lodash' ) ;
66const path = require ( 'path' ) ;
7- const semver = require ( 'semver' ) ;
87const utils = require ( '../lib/utils.js' ) ;
98const warnings = require ( '../lib/warnings.js' ) ;
109
@@ -161,25 +160,26 @@ const getServices = options => ({
161160/*
162161 * Helper to get the phar build command
163162 */
164- const getDbTooling = database => {
165- // Make sure we strip out any version number
166- const db = database . split ( ':' ) [ 0 ] ;
167- const ver = database . split ( ':' ) [ 1 ] ;
163+ const getDbTooling = ( database , options ) => {
164+ const semver = options . _app . _lando . utils . getSemver ( ) ;
165+ const [ db , ver ] = database . split ( ':' ) ;
168166 // Choose wisely
169167 if ( db === 'mysql' ) {
170- return { mysql : mysqlCli } ;
171- } else if ( db === 'mariadb' && ver < 10.4 ) {
168+ return { mysql : mysqlCli } ;
169+ } else if ( db === 'mariadb' && semver . lt ( semver . coerce ( ver ) , ' 10.4.0' ) ) {
172170 // Use mysql command for MariaDB 10.3.x and below
173- return { mysql : mysqlCli } ;
171+ return { mysql : mysqlCli } ;
174172 } else if ( db === 'mariadb' ) {
175- return { mariadb : mariadbCli } ;
173+ return { mariadb : mariadbCli } ;
176174 } else if ( db === 'postgres' ) {
177- return { psql : postgresCli } ;
175+ return { psql : postgresCli } ;
178176 } else if ( db === 'mongo' ) {
179- return { mongo : {
180- service : 'database' ,
181- description : 'Drop into the mongo shell' ,
182- } } ;
177+ return {
178+ mongo : {
179+ service : 'database' ,
180+ description : 'Drop into the mongo shell' ,
181+ }
182+ } ;
183183 }
184184} ;
185185
@@ -192,7 +192,7 @@ const getProxy = (options, proxyService = 'appserver') => {
192192 // add
193193 urls . push ( `${ options . app } .${ options . _app . _config . domain } ` ) ;
194194 // return
195- return { [ proxyService ] : _ . uniq ( _ . compact ( urls ) ) } ;
195+ return { [ proxyService ] : _ . uniq ( _ . compact ( urls ) ) } ;
196196} ;
197197
198198/*
@@ -215,7 +215,7 @@ const getServiceConfig = (options, types = ['php', 'server', 'vhosts']) => {
215215/*
216216 * Helper to get tooling
217217 */
218- const getTooling = options => _ . merge ( { } , toolingDefaults , getDbTooling ( options . database ) ) ;
218+ const getTooling = options => _ . merge ( { } , toolingDefaults , getDbTooling ( options . database , options ) ) ;
219219
220220/*
221221 * Build Drupal 7
@@ -228,22 +228,26 @@ module.exports = {
228228 composer : { } ,
229229 confSrc : __dirname ,
230230 config : { } ,
231- database : 'mysql' ,
231+ database : 'mysql:5.7 ' ,
232232 defaultFiles : {
233233 php : 'php.ini' ,
234234 } ,
235235 php : '7.2' ,
236- tooling : { drush : {
237- service : 'appserver' ,
238- } } ,
239- via : 'apache' ,
236+ tooling : {
237+ drush : {
238+ service : 'appserver' ,
239+ }
240+ } ,
241+ via : 'apache:2.4' ,
240242 webroot : '.' ,
241243 xdebug : false ,
242244 proxy : { } ,
243245 } ,
244246 builder : ( parent , config ) => class LandoDrupal extends parent {
245247 constructor ( id , options = { } ) {
248+ const semver = options . _app . _lando . utils . getSemver ( ) ;
246249 options = _ . merge ( { } , config , options ) ;
250+
247251 // Set the default drush version if we don't have it
248252 if ( ! _ . has ( options , 'drush' ) ) options . drush = ( options . php === '5.3' ) ? DRUSH7 : DRUSH8 ;
249253
@@ -264,12 +268,16 @@ module.exports = {
264268 }
265269
266270 // Set legacy envars
267- options . services = _ . merge ( { } , options . services , { appserver : { overrides : {
268- environment : {
269- SIMPLETEST_BASE_URL : ( options . via === 'nginx' ) ? 'https://appserver_nginx' : 'https://appserver' ,
270- SIMPLETEST_DB : `mysql://${ options . recipe } :${ options . recipe } @database/${ options . recipe } ` ,
271- } ,
272- } } } ) ;
271+ options . services = _ . merge ( { } , options . services , {
272+ appserver : {
273+ overrides : {
274+ environment : {
275+ SIMPLETEST_BASE_URL : ( options . via === 'nginx' ) ? 'https://appserver_nginx' : 'https://appserver' ,
276+ SIMPLETEST_DB : `mysql://${ options . recipe } :${ options . recipe } @database/${ options . recipe } ` ,
277+ } ,
278+ }
279+ }
280+ } ) ;
273281
274282 // Switch the proxy service if needed
275283 if ( ! _ . has ( options , 'proxyService' ) ) {
0 commit comments