Skip to content

EspoCRM – Open Source CRM Application

Build targetVersion parameter

Yurii5c25234cedbd
diff --git a/Gruntfile.js b/Gruntfile.js
index e9d3ed78b7..55869e262d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -34,6 +34,9 @@
* * `grunt release` - full build zipped with upgrade packages`;
* * `grunt test` - build for tests running;
* * `grunt run-tests` - build and run unit and integration tests.
+ *
+ * Parameters:
+ * `--targetVersion` – overrides the target version.
*/
const fs = require('fs');
@@ -50,6 +53,8 @@ module.exports = grunt => {
const pkg = grunt.file.readJSON('package.json');
+ const version = grunt.option('targetVersion') || pkg.version;
+
const originalLibDir = 'client/lib/original';
const libsBundleFileList = [
@@ -164,7 +169,7 @@ module.exports = grunt => {
'client/css/espo/*',
],
final: ['build/tmp'],
- release: ['build/EspoCRM-' + pkg.version],
+ release: ['build/EspoCRM-' + version],
beforeFinal: {src: cleanupBeforeFinal},
beforeFinalTest: {src: cleanupBeforeFinalTest},
},
@@ -258,7 +263,7 @@ module.exports = grunt => {
dot: true,
src: '**',
cwd: 'build/tmp',
- dest: 'build/EspoCRM-<%= pkg.version %>/',
+ dest: 'build/EspoCRM-' + version,
},
},
@@ -268,7 +273,7 @@ module.exports = grunt => {
patterns: [
{
match: 'version',
- replacement: '<%= pkg.version %>',
+ replacement: version,
}
]
},
@@ -353,12 +358,12 @@ module.exports = grunt => {
grunt.registerTask('chmod-folders', () => {
cp.execSync(
"find . -type d -exec chmod 755 {} +",
- {cwd: 'build/EspoCRM-' + pkg.version}
+ {cwd: 'build/EspoCRM-' + version}
);
});
grunt.registerTask('chmod-multiple', () => {
- const dirPath = 'build/EspoCRM-' + pkg.version;
+ const dirPath = 'build/EspoCRM-' + version;
const fileList = [
{
@@ -479,7 +484,7 @@ module.exports = grunt => {
const resolve = this.async();
- const folder = 'EspoCRM-' + pkg.version;
+ const folder = 'EspoCRM-' + version;
const zipPath = 'build/' + folder + '.zip';
if (fs.existsSync(zipPath)) {
diff --git a/diff.js b/diff.js
index 10c3fe8d07..9c898c70b7 100644
--- a/diff.js
+++ b/diff.js
@@ -59,6 +59,7 @@ let isAll = false;
let withVendor = true;
let forceScripts = false;
let isClosest = false;
+let targetVersion = null;
if (process.argv.length > 1) {
for (const i in process.argv) {
@@ -86,6 +87,10 @@ if (process.argv.length > 1) {
if (~process.argv[i].indexOf('--acceptedVersion=')) {
acceptedVersionName = process.argv[i].substr(('--acceptedVersion=').length);
}
+
+ if (process.argv[i].includes('--targetVersion=')) {
+ targetVersion = process.argv[i].substr(('--targetVersion=').length);
+ }
}
}
@@ -100,6 +105,7 @@ const diff = new Diff(espoPath, {
withVendor: withVendor,
forceScripts: forceScripts,
acceptedVersionName: acceptedVersionName,
+ targetVersion: targetVersion,
});
(() => {
diff --git a/js/diff.js b/js/diff.js
index 1e8f9cfb05..8519d34053 100644
--- a/js/diff.js
+++ b/js/diff.js
@@ -38,6 +38,9 @@ const exec = cp.exec;
/**
* Builds upgrade packages.
+ *
+ * Parameters:
+ * `--targetVersion` – overrides the target version.
*/
class Diff
{
@@ -74,7 +77,7 @@ class Diff
_getPreviousVersionList(closest) {
const dirInitial = process.cwd();
- const version = (require(this.espoPath + '/package.json') || {}).version;
+ const version = this.getTargetVersion();
process.chdir(this.espoPath);
@@ -146,6 +149,10 @@ class Diff
return versionFromList;
}
+ getTargetVersion() {
+ return this.params.targetVersion ?? (require(this.espoPath + '/package.json') || {}).version;
+ }
+
buildMultipleUpgradePackages(versionFromList) {
const params = this.params;
const espoPath = this.espoPath;
@@ -179,7 +186,7 @@ class Diff
const withVendor = params.withVendor ?? true;
const forceScripts = params.forceScripts;
- const version = (require(espoPath + '/package.json') || {}).version;
+ const version = this.getTargetVersion();
const composerData = require(espoPath + '/composer.json') || {};
const currentPath = espoPath;