Merge branch 'stable'

This commit is contained in:
Yuri Kuznetsov
2019-12-09 16:00:32 +02:00
4 changed files with 230 additions and 156 deletions
+5 -1
View File
@@ -160,9 +160,11 @@ define('ui', [], function () {
diffHeight = diffHeight + options.bodyDiffHeight;
}
var h = $window.height();
if (this.fitHeight || options.fullHeight) {
var processResize = function () {
var windowHeight = $window.height();
var windowHeight = window.innerHeight;
var windowWidth = $window.width();
if (!options.fullHeight && windowHeight < 512) {
@@ -178,6 +180,7 @@ define('ui', [], function () {
};
if (options.fullHeight) {
cssParams.height = (windowHeight - diffHeight) + 'px';
this.$el.css('paddingRight', 0);
} else {
if (windowWidth <= options.screenWidthXs) {
@@ -337,6 +340,7 @@ define('ui', [], function () {
this.onRemove();
this.$el.remove();
$(this).off();
$(window).off('resize.modal-height');
};
var Ui = Espo.Ui = Espo.ui = {
+199 -126
View File
@@ -25,153 +25,226 @@
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
var exec = require('child_process').exec;
var versionFrom = process.argv[2];
if (process.argv.length < 3) {
throw new Error("No 'version from' passed");
}
var acceptedVersionName = versionFrom;
var isDev = false;
var isAll = false;
if (process.argv.length > 2) {
if (process.argv.length > 1) {
for (var i in process.argv) {
if (process.argv[i] === '--dev') {
isDev = true;
}
if (process.argv[i] === '--all') {
isAll = true;
}
if (~process.argv[i].indexOf('--acceptedVersion=')) {
acceptedVersionName = process.argv[i].substr(('--acceptedVersion=').length);
}
}
}
var path = require('path');
var fs = require('fs');
var sys = require('util')
var version = (require('./package.json') || {}).version;
if (isAll) {
var version = (require('./package.json') || {}).version;
var currentPath = path.dirname(fs.realpathSync(__filename));
execute('git tag -l --sort=-v:refname # reverse', function (tagsString) {
var tagList = tagsString.trim().split("\n");
var versionFromList = [];
var buildRelPath = 'build/EspoCRM-' + version;
var buildPath = currentPath + '/' + buildRelPath;
var diffFilePath = currentPath + '/build/diff';
var upgradePath = currentPath + '/build/EspoCRM-upgrade-' + acceptedVersionName + '-to-' + version;
var minorVersionNumber = version.split('.')[1];
var hotfixVersionNumber = version.split('.')[2];
var exec = require('child_process').exec;
for (var i = 0; i < tagList.length; i++) {
var tag = tagList[i];
if (!~tag.indexOf('beta') && !~tag.indexOf('alpha')) {
var minorVersionNumberI = tag.split('.')[1];
if (minorVersionNumberI !== minorVersionNumber) {
versionFromList.push(tag);
break;
}
}
}
if (hotfixVersionNumber !== '0') {
for (var i = 0; i < tagList.length; i++) {
var tag = tagList[i];
if (!~tag.indexOf('beta') && !~tag.indexOf('alpha')) {
versionFromList.push(tag);
break;
}
}
}
async function buildMultiple () {
for (const versionFrom of versionFromList) {
await buildUpgradePackage(versionFrom, {
isDev: isDev,
});
}
}
buildMultiple();
});
} else {
if (process.argv.length < 3) {
throw new Error("No 'version' specified.");
}
buildUpgradePackage(versionFrom, {
acceptedVersionName: acceptedVersionName,
isDev: isDev,
});
}
function buildUpgradePackage(versionFrom, params)
{
return new Promise(function (resolve) {
var acceptedVersionName = params.acceptedVersionName || versionFrom;
var path = require('path');
var fs = require('fs');
var sys = require('util');
var version = (require('./package.json') || {}).version;
var composerData = require('./composer.json') || {};
var currentPath = path.dirname(fs.realpathSync(__filename));
var buildRelPath = 'build/EspoCRM-' + version;
var buildPath = currentPath + '/' + buildRelPath;
var diffFilePath = currentPath + '/build/diff';
var upgradePath = currentPath + '/build/EspoCRM-upgrade-' + acceptedVersionName + '-to-' + version;
var deleteDirRecursively = function (path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file, index) {
var curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
deleteDirRecursively(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
deleteDirRecursively(diffFilePath);
deleteDirRecursively(upgradePath);
execute('git rev-parse --abbrev-ref HEAD', function (branch) {
branch = branch.trim();
if (branch !== 'master' && branch !== 'stable' && branch.indexOf('hotfix/') !== 0) {
console.log('\x1b[33m%s\x1b[0m', "Warning! You are on " + branch + " branch.");
}
});
execute('git diff --name-only ' + versionFrom, function (stdout) {
if (!fs.existsSync(upgradePath)) {
fs.mkdirSync(upgradePath);
}
if (!fs.existsSync(upgradePath + '/files')) {
fs.mkdirSync(upgradePath + '/files');
}
if (!fs.existsSync(buildPath)) {
throw new Error("EspoCRM is not built. Need to run grunt before.");
}
process.chdir(buildPath);
var fileList = [];
(stdout || '').split('\n').forEach(function (file) {
if (file == '') {
return;
}
fileList.push(file);
});
fileList.push('client/espo.min.js');
fileList.push('client/espo.min.js.map');
fs.readdirSync('client/css/espo/').forEach(function (file) {
fileList.push('client/css/espo/' + file);
});
fs.writeFileSync(diffFilePath, fileList.join('\n'));
execute('git diff --name-only --diff-filter=D ' + versionFrom, function (stdout) {
var deletedFileList = [];
(stdout || '').split('\n').forEach(function (file) {
if (file == '') {
return;
}
deletedFileList.push(file);
});
execute('xargs -a ' + diffFilePath + ' cp --parents -t ' + upgradePath + '/files ' , function (stdout) {
var d = new Date();
var monthN = ((d.getMonth() + 1).toString());
monthN = monthN.length == 1 ? '0' + monthN : monthN;
var dateN = d.getDate().toString();
dateN = dateN.length == 1 ? '0' + dateN : dateN;
var date = d.getFullYear().toString() + '-' + monthN + '-' + dateN.toString();
execute('git tag', function (stdout) {
var versionList = [];
tagList = stdout.split('\n').forEach(function (tag) {
if (tag == versionFrom) {
versionList.push(tag);
}
if (!tag || tag == version) {
return;
}
});
if (isDev) {
versionList = [];
}
var name = acceptedVersionName+" to "+version;
var manifest = {
"name": "EspoCRM Upgrade "+name,
"type": "upgrade",
"version": version,
"acceptableVersions": versionList,
"php": [composerData.require.php],
"releaseDate": date,
"author": "EspoCRM",
"description": "",
"delete": deletedFileList,
};
fs.writeFileSync(upgradePath + '/manifest.json', JSON.stringify(manifest, null, ' '));
fs.unlinkSync(diffFilePath);
console.log("Upgrade package is built: "+name+"");
resolve();
});
});
});
});
});
}
function execute(command, callback) {
exec(command, function(error, stdout, stderr) {
callback(stdout);
});
};
var deleteDirRecursively = function (path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file, index) {
var curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
deleteDirRecursively(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
deleteDirRecursively(diffFilePath);
deleteDirRecursively(upgradePath);
execute('git rev-parse --abbrev-ref HEAD', function (branch) {
branch = branch.trim();
if (branch !== 'master' && branch !== 'stable' && branch.indexOf('hotfix/') !== 0) {
console.log('\x1b[33m%s\x1b[0m', "Warning! You are on " + branch + " branch.");
}
});
execute('git diff --name-only ' + versionFrom, function (stdout) {
if (!fs.existsSync(upgradePath)) {
fs.mkdirSync(upgradePath);
}
if (!fs.existsSync(upgradePath + '/files')) {
fs.mkdirSync(upgradePath + '/files');
}
process.chdir(buildPath);
var fileList = [];
(stdout || '').split('\n').forEach(function (file) {
if (file == '') {
return;
}
fileList.push(file);
});
fileList.push('client/espo.min.js');
fileList.push('client/espo.min.js.map');
fs.readdirSync('client/css/espo/').forEach(function (file) {
fileList.push('client/css/espo/' + file);
});
fs.writeFileSync(diffFilePath, fileList.join('\n'));
execute('git diff --name-only --diff-filter=D ' + versionFrom, function (stdout) {
var deletedFileList = [];
(stdout || '').split('\n').forEach(function (file) {
if (file == '') {
return;
}
deletedFileList.push(file);
});
execute('xargs -a ' + diffFilePath + ' cp --parents -t ' + upgradePath + '/files ' , function (stdout) {
var d = new Date();
var monthN = ((d.getMonth() + 1).toString());
monthN = monthN.length == 1 ? '0' + monthN : monthN;
var dateN = d.getDate().toString();
dateN = dateN.length == 1 ? '0' + dateN : dateN;
var date = d.getFullYear().toString() + '-' + monthN + '-' + dateN.toString();
execute('git tag', function (stdout) {
var versionList = [];
tagList = stdout.split('\n').forEach(function (tag) {
if (tag == versionFrom) {
versionList.push(tag);
}
if (!tag || tag == version) {
return;
}
});
if (isDev) {
versionList = [];
}
var manifest = {
"name": "EspoCRM Upgrade "+acceptedVersionName+" to "+version,
"type": "upgrade",
"version": version,
"acceptableVersions": versionList,
"releaseDate": date,
"author": "EspoCRM",
"description": "",
"delete": deletedFileList
}
fs.writeFileSync(upgradePath + '/manifest.json', JSON.stringify(manifest, null, ' '));
console.log("Upgrade package is built.");
});
fs.unlinkSync(diffFilePath);
});
});
});
};
+25 -28
View File
@@ -56,14 +56,11 @@ class Installer
'timeFormat',
'timeZone',
'weekStart',
'defaultCurrency' => array(
'currencyList', 'defaultCurrency',
),
'defaultCurrency',
'smtpSecurity',
'language',
);
public function __construct()
{
$this->initialize();
@@ -189,15 +186,20 @@ class Installer
return $this->language;
}
public function getLanguageList()
public function getLanguageList($isTranslated = true)
{
$config = $this->app->getContainer()->get('config');
$languageList = $this->app->getContainer()->get('config')->get('languageList');
$languageList = $config->get('languageList');
if ($isTranslated) {
return $this->getLanguage()->translate('language', 'options', 'Global', $languageList);
}
$translated = $this->getLanguage()->translate('language', 'options', 'Global', $languageList);
return $languageList;
}
return $translated;
protected function getCurrencyList()
{
return $this->app->getMetadata()->get('app.currency.list');
}
public function getInstallerConfigData()
@@ -309,9 +311,9 @@ class Installer
public function setPreferences($preferences)
{
$currencyList = $this->getConfig()->get('currencyList', array());
if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) {
$currencyList = $this->getConfig()->get('currencyList', []);
if (isset($preferences['defaultCurrency']) && !in_array($preferences['defaultCurrency'], $currencyList)) {
$preferences['currencyList'] = array($preferences['defaultCurrency']);
$preferences['baseCurrency'] = $preferences['defaultCurrency'];
}
@@ -324,7 +326,6 @@ class Installer
return $res;
}
protected function createRecords()
{
$records = include('install/core/afterInstall/records.php');
@@ -458,29 +459,25 @@ class Installer
public function getSettingDefaults()
{
$defaults = array();
$settingDefs = $this->app->getMetadata()->get('entityDefs.Settings.fields');
foreach ($this->settingList as $fieldName => $field) {
$defaults = array();
if (is_array($field)) {
$fieldDefaults = array();
foreach ($field as $subField) {
if (isset($settingDefs[$subField])) {
$fieldDefaults = array_merge($fieldDefaults, $this->translateSetting($subField, $settingDefs[$subField]));
}
}
$defaults[$fieldName] = $fieldDefaults;
foreach ($this->settingList as $fieldName) {
} else if (isset($settingDefs[$field])) {
if (!isset($settingDefs[$fieldName])) continue;
$defaults[$field] = $this->translateSetting($field, $settingDefs[$field]);
switch ($fieldName) {
case 'defaultCurrency':
$settingDefs['defaultCurrency']['options'] = $this->getCurrencyList();
break;
case 'language':
$settingDefs['language']['options'] = $this->getLanguageList(false);
break;
}
}
if (isset($defaults['language'])) {
$defaults['language']['options'] = $this->getLanguageList();
$defaults[$fieldName] = $this->translateSetting($fieldName, $settingDefs[$fieldName]);
}
return $defaults;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "5.7.8",
"version": "5.7.9",
"description": "",
"main": "index.php",
"repository": {