@lando/drupal
Version:
A Lando plugin that provides a tight integration with Drupal.
88 lines (80 loc) • 2.2 kB
JavaScript
// Modules
const _ = require('lodash');
const path = require('path');
/*
* Helper to get a phar download and setupcommand
* @TODO: clean this mess up
*/
exports.getPhar = (url, src, dest, check = 'true') => {
// Arrayify the check if needed
if (_.isString(check)) check = [check];
// Phar install command
const pharInstall = [
['curl', url, '-LsS', '-o', src],
['chmod', '+x', src],
['mv', src, dest],
check,
];
// Return
return _.map(pharInstall, cmd => cmd.join(' ')).join(' && ');
};
/*
* Helper to get DRUSH phar url
*/
const getDrushUrl = version => `https://github.com/drush-ops/drush/releases/download/${version}/drush.phar`;
/*
* Helper to get the phar build command
*/
exports.getDrush = (version, status) => exports.getPhar(
getDrushUrl(version),
'/tmp/drush.phar',
'/usr/local/bin/drush',
status,
);
/*
* Helper to get a phar download and setupcommand
* @TODO: clean this mess up
*/
exports.getPhar = (url, src, dest, check = 'true') => {
// Arrayify the check if needed
if (_.isString(check)) check = [check];
// Phar install command
const pharInstall = [
['curl', url, '-LsS', '-o', src],
['chmod', '+x', src],
['mv', src, dest],
check,
];
// Return
return _.map(pharInstall, cmd => cmd.join(' ')).join(' && ');
};
/*
* Helper to get service config
*/
exports.getServiceConfig = (options, types = ['php', 'server', 'vhosts']) => {
const config = {};
_.forEach(types, type => {
if (_.has(options, `config.${type}`)) {
config[type] = options.config[type];
} else if (!_.has(options, `config.${type}`) && _.has(options, `defaultFiles.${type}`)) {
if (_.has(options, 'confDest')) {
config[type] = path.join(options.confDest, options.defaultFiles[type]);
}
}
});
return config;
};
/*
* Parse config into raw materials for our factory
*/
exports.parseConfig = (recipe, app) => _.merge({}, _.get(app, 'config.config', {}), {
_app: app,
app: app.name,
confDest: path.join(app._config.userConfRoot, 'config', recipe),
home: app._config.home,
project: app.project,
recipe,
root: app.root,
userConfRoot: app._config.userConfRoot,
});
;