UNPKG

@aivec/wp-docker-dev-factory

Version:

Spin up local WordPress environments with Docker.

77 lines (76 loc) 3.06 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var validateFtpConfig_1 = __importDefault(require("./validateFtpConfig")); var checkJsonKeyExistence_1 = __importDefault(require("./checkJsonKeyExistence")); var validateLocalPaths_1 = __importDefault(require("./validateLocalPaths")); var checkIsArray_1 = __importDefault(require("./checkIsArray")); var validatePrivateRemoteFilesConfig_1 = __importDefault(require("./validatePrivateRemoteFilesConfig")); var validateSSHConfig_1 = __importDefault(require("./validateSSHConfig")); var validatePhpVersion_1 = __importDefault(require("./validatePhpVersion")); var checkIsString_1 = __importDefault(require("./checkIsString")); var validateFullUrl_1 = __importDefault(require("./validateFullUrl")); var validateConfig = function (config) { (0, checkJsonKeyExistence_1.default)(config, 'instanceName'); if (config.phpVersion) { (0, validatePhpVersion_1.default)(config.phpVersion); } var arrayTypeKeys = [ 'localPlugins', 'localThemes', 'downloadPlugins', 'downloadThemes', 'customInitScripts', 'ftp', 'ssh', ]; arrayTypeKeys.forEach(function (key) { if (config[key]) { (0, checkIsArray_1.default)(config, key); } }); if (config.localPlugins) { (0, validateLocalPaths_1.default)('plugin', config.localPlugins, config.workingdir); } if (config.localThemes) { (0, validateLocalPaths_1.default)('theme', config.localThemes, config.workingdir); } if (config.image) { (0, validateLocalPaths_1.default)('image file', [config.image], config.workingdir); } if (config.uploads) { (0, validateLocalPaths_1.default)('uploads folder', [config.uploads], config.workingdir); } if (config.customInitScripts) { (0, validateLocalPaths_1.default)('script', config.customInitScripts, config.workingdir); // vaidateCustomScriptsMode(config.customInitScripts, workingdir); } if (config.uploadsUrl) { (0, checkIsString_1.default)(config, 'uploadsUrl'); } if (config.hostName) { (0, checkIsString_1.default)(config, 'hostName'); } (0, validateFullUrl_1.default)(config); var prfConfigKeys = ['ssh', 'ftp']; prfConfigKeys.forEach(function (key) { if (config[key]) { (0, validatePrivateRemoteFilesConfig_1.default)(config[key], key); } }); if (config.ftp) { (0, validateFtpConfig_1.default)(config.ftp); } if (config.ssh) { (0, validateSSHConfig_1.default)(config.ssh, config.workingdir); } if (config.database) { var mysqlDumpfile = config.database.mysqlDumpfile; if (mysqlDumpfile) { (0, validateLocalPaths_1.default)('MySQL dump file', [mysqlDumpfile], config.workingdir); } } }; exports.default = validateConfig;