mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Split increase_version file to work with build folder
This commit is contained in:
parent
7adfe9cce4
commit
8865ded4bd
@ -1,3 +1,2 @@
|
||||
call node .\scripts\node\increase_version.js
|
||||
call .\scripts\batch\build.bat
|
||||
call .\scripts\batch\package.bat
|
||||
@ -1,3 +1,6 @@
|
||||
REM dll version file must be set before compilation and changes can be committed
|
||||
call node .\scripts\node\set_version_dll.js
|
||||
|
||||
cd backend
|
||||
msbuild olympus.sln /t:Build /p:Configuration=Release
|
||||
cd ..
|
||||
@ -22,4 +25,7 @@ cd ..
|
||||
|
||||
cd manager
|
||||
call npm run build-release
|
||||
cd ..
|
||||
cd ..
|
||||
|
||||
REM other version tags are changed after compilation only in the build folder and should not be committed
|
||||
call node .\scripts\node\set_version_text.js
|
||||
@ -34,7 +34,6 @@ fs.readFile("./version.json", "utf8", (error, data) => {
|
||||
const minorminor = arr[2];
|
||||
|
||||
throughDirectory("./backend");
|
||||
throughDirectory("./build");
|
||||
|
||||
files.forEach((file) => {
|
||||
fs.readFile(file, 'utf8', function (err,data) {
|
||||
@ -42,13 +41,6 @@ fs.readFile("./version.json", "utf8", (error, data) => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
if (data.search(/{{OLYMPUS_VERSION_NUMBER}}/g) >= 0) {
|
||||
console.log(`Replacing version in ${file}`);
|
||||
|
||||
data = data.replace(/{{OLYMPUS_VERSION_NUMBER}}/g, `v${major}.${minor}.${minorminor}`);
|
||||
data = data.replace(/{{OLYMPUS_COMMIT_HASH}}/g, revision);
|
||||
fileChanged = true;
|
||||
}
|
||||
|
||||
if (data.search(/FILEVERSION \d,\d,\d/g) >= 0) {
|
||||
console.log(`Replacing version in ${file}`);
|
||||
61
scripts/node/set_version_text.js
Normal file
61
scripts/node/set_version_text.js
Normal file
@ -0,0 +1,61 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
let files = [];
|
||||
|
||||
const revision = require('child_process').execSync('git rev-parse --short HEAD').toString().trim();
|
||||
|
||||
function throughDirectory(directory) {
|
||||
fs.readdirSync(directory).forEach(file => {
|
||||
const absolute = path.join(directory, file);
|
||||
if (!file.includes("increase_version.js") && !file.includes("node_modules")) {
|
||||
if (fs.statSync(absolute).isDirectory())
|
||||
{
|
||||
return throughDirectory(absolute);
|
||||
}
|
||||
else {
|
||||
return files.push(absolute);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fs.readFile("./version.json", "utf8", (error, data) => {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
return;
|
||||
}
|
||||
const versionJSON = JSON.parse(data);
|
||||
var version = versionJSON["version"];
|
||||
console.log(`Setting version number to ${version}`);
|
||||
version = version.replace("v", "");
|
||||
var arr = version.split(".");
|
||||
const major = arr[0];
|
||||
const minor = arr[1];
|
||||
const minorminor = arr[2];
|
||||
|
||||
throughDirectory("./build");
|
||||
|
||||
files.forEach((file) => {
|
||||
fs.readFile(file, 'utf8', function (err,data) {
|
||||
var fileChanged = false;
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
if (data.search(/{{OLYMPUS_VERSION_NUMBER}}/g) >= 0) {
|
||||
console.log(`Replacing version in ${file}`);
|
||||
|
||||
data = data.replace(/{{OLYMPUS_VERSION_NUMBER}}/g, `v${major}.${minor}.${minorminor}`);
|
||||
data = data.replace(/{{OLYMPUS_COMMIT_HASH}}/g, revision);
|
||||
fileChanged = true;
|
||||
}
|
||||
|
||||
if (fileChanged) {
|
||||
fs.writeFile(file, data, 'utf8', (err) => {
|
||||
if (err) return console.log(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user