Skip to content

Commit 7efa6dc

Browse files
committed
Remove semver dependency
1 parent f4b344f commit 7efa6dc

File tree

4 files changed

+39
-31
lines changed

4 files changed

+39
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})
22

33
* Added default config values to the `.lando.yml` file after init.
4+
* Removed `semver` dependency from the plugin.
45

56
## v1.12.0 - [January 16, 2025](https://github.com/lando/drupal/releases/tag/v1.12.0)
67

builders/_drupaly.js

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
const fs = require('fs');
55
const _ = require('lodash');
66
const path = require('path');
7-
const semver = require('semver');
87
const utils = require('../lib/utils.js');
98
const 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')) {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
"@lando/mysql": "^1.5.0",
4949
"@lando/php": "^1.7.1",
5050
"@lando/postgres": "^1.4.4",
51-
"lodash": "^4.17.21",
52-
"semver": "^7.5.4"
51+
"lodash": "^4.17.21"
5352
},
5453
"devDependencies": {
5554
"@babel/eslint-parser": "^7.16.0",

0 commit comments

Comments
 (0)