mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Refactoring of building scripts
This commit is contained in:
25
scripts/batch/build.bat
Normal file
25
scripts/batch/build.bat
Normal file
@@ -0,0 +1,25 @@
|
||||
cd backend
|
||||
msbuild olympus.sln /t:Build /p:Configuration=Release
|
||||
cd ..
|
||||
|
||||
cd client
|
||||
rmdir /s /q hgt
|
||||
call npm install
|
||||
call npm run emit-declarations
|
||||
call npm run build-release
|
||||
|
||||
cd plugins\controltips
|
||||
call npm install
|
||||
call npm run build-release
|
||||
cd ..\..
|
||||
|
||||
cd plugins\databasemanager
|
||||
call npm install
|
||||
call npm run build-release
|
||||
cd ..\..
|
||||
|
||||
cd ..
|
||||
|
||||
cd manager
|
||||
call npm run build-release
|
||||
cd ..
|
||||
11
scripts/batch/installer.bat
Normal file
11
scripts/batch/installer.bat
Normal file
@@ -0,0 +1,11 @@
|
||||
@echo OFF
|
||||
|
||||
SET PATH=%PATH%;%WINDIR%\System32;%WINDIR%\System32\WindowsPowerShell\v1.0;
|
||||
|
||||
WHERE /q powershell
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
.\scripts\install.bat
|
||||
) else (
|
||||
powershell ".\scripts\install.bat | tee output.log"
|
||||
)
|
||||
|
||||
39
scripts/batch/package.bat
Normal file
39
scripts/batch/package.bat
Normal file
@@ -0,0 +1,39 @@
|
||||
rmdir /s /q package
|
||||
mkdir package
|
||||
|
||||
REM copy the main configuration file
|
||||
echo F|xcopy /Y .\olympus.json .\package\olympus.json
|
||||
|
||||
REM copy the installation scripts
|
||||
echo F|xcopy /Y .\scripts\batch\install.bat .\package\Scripts\install.bat
|
||||
echo F|xcopy /Y .\scripts\batch\installer.bat .\package\installer.bat
|
||||
|
||||
REM copy the hooks script
|
||||
echo F|xcopy /Y .\scripts\lua\hooks\OlympusHook.lua .\package\Scripts\OlympusHook.lua
|
||||
|
||||
REM copy the lua scripts
|
||||
echo F|xcopy /Y .\scripts\lua\backend .\package\mod\scripts
|
||||
|
||||
REM copy the mod folder
|
||||
echo D|xcopy /Y /S /E .\mod .\package\mod
|
||||
|
||||
REM copy the backend dll
|
||||
echo F|xcopy /Y /I .\build\backend\bin\*.dll .\package\mod\bin
|
||||
|
||||
REM copy the client
|
||||
echo D|xcopy /Y /S /E .\build\client .\package\client
|
||||
|
||||
REM copy the manager
|
||||
echo D|xcopy /Y /S /E .\build\manager .\package\manager
|
||||
|
||||
REM copy the images folder
|
||||
echo D|xcopy /Y /S /E .\img\ .\package\img
|
||||
|
||||
REM copy the instructions and text files
|
||||
echo F|xcopy /Y .\LEGAL.txt .\package\LEGAL.txt
|
||||
echo F|xcopy /Y .\INSTRUCTIONS.txt .\package\INSTRUCTIONS.txt
|
||||
echo F|xcopy /Y .\notes.txt .\package\notes.txt
|
||||
|
||||
REM copy the dependencies
|
||||
echo D|xcopy /Y /S /E .\dependencies .\package\dependencies
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,24 @@
|
||||
function disableAutoCapture(airbaseName)
|
||||
trigger.action.outText("Olympus.disableAutoCapture " .. airbaseName, 2)
|
||||
local airbase = Airbase.getByName(airbaseName)
|
||||
if airbase then
|
||||
airbase:autoCapture(false)
|
||||
trigger.action.outText("Olympus.disableAutoCapture " .. airbaseName .. " completed successfully", 2)
|
||||
else
|
||||
trigger.action.outText("Olympus.disableAutoCapture failed", 2)
|
||||
end
|
||||
end
|
||||
|
||||
function setAirbaseCoalition(airbaseName, coalitionColor)
|
||||
trigger.action.outText("Olympus.setAirbaseCoalition trying to set " .. airbaseName .. " to " .. coalitionColor, 2)
|
||||
local airbase = Airbase.getByName(airbaseName)
|
||||
if airbase then
|
||||
disableAutoCapture(airbaseName)
|
||||
airbase:setCoalition(coalition.side[coalitionColor])
|
||||
trigger.action.outText("Olympus.setAirbaseCoalition " .. airbaseName .. " set to " .. coalitionColor .. " completed successfully", 5)
|
||||
else
|
||||
trigger.action.outText("Olympus.setAirbaseCoalition Airbase not found: " .. airbaseName, 5)
|
||||
end
|
||||
end
|
||||
|
||||
function disableAutoCapture(airbaseName)
|
||||
trigger.action.outText("Olympus.disableAutoCapture " .. airbaseName, 2)
|
||||
local airbase = Airbase.getByName(airbaseName)
|
||||
if airbase then
|
||||
airbase:autoCapture(false)
|
||||
trigger.action.outText("Olympus.disableAutoCapture " .. airbaseName .. " completed successfully", 2)
|
||||
else
|
||||
trigger.action.outText("Olympus.disableAutoCapture failed", 2)
|
||||
end
|
||||
end
|
||||
|
||||
function setAirbaseCoalition(airbaseName, coalitionColor)
|
||||
trigger.action.outText("Olympus.setAirbaseCoalition trying to set " .. airbaseName .. " to " .. coalitionColor, 2)
|
||||
local airbase = Airbase.getByName(airbaseName)
|
||||
if airbase then
|
||||
disableAutoCapture(airbaseName)
|
||||
airbase:setCoalition(coalition.side[coalitionColor])
|
||||
trigger.action.outText("Olympus.setAirbaseCoalition " .. airbaseName .. " set to " .. coalitionColor .. " completed successfully", 5)
|
||||
else
|
||||
trigger.action.outText("Olympus.setAirbaseCoalition Airbase not found: " .. airbaseName, 5)
|
||||
end
|
||||
end
|
||||
|
||||
setAirbaseCoalition("Khasab", "RED")
|
||||
79
scripts/node/increase_version.js
Normal file
79
scripts/node/increase_version.js
Normal file
@@ -0,0 +1,79 @@
|
||||
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(".");
|
||||
|
||||
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 (data.search(/FILEVERSION \d,\d,\d/g) >= 0) {
|
||||
console.log(`Replacing version in ${file}`);
|
||||
var data = data.replace(/FILEVERSION \d,\d,\d/g, `FILEVERSION ${major},${minor},${minorminor}`);
|
||||
fileChanged = true;
|
||||
}
|
||||
|
||||
if (data.search(/VALUE "FileVersion", "\d.\d.\d.0"/g) >= 0) {
|
||||
console.log(`Replacing version in ${file}`);
|
||||
data = data.replace(/VALUE "FileVersion", "\d.\d.\d.0"/g, `VALUE "FileVersion", "${major}.${minor}.${minorminor}.0"`);
|
||||
fileChanged = true;
|
||||
}
|
||||
|
||||
if (data.search(/VALUE "ProductVersion", "\d.\d.\d.0"/g) >= 0) {
|
||||
console.log(`Replacing version in ${file}`);
|
||||
data = data.replace(/VALUE "ProductVersion", "\d.\d.\d.0"/g, `VALUE "ProductVersion", "${major}.${minor}.${minorminor}.0"`);
|
||||
fileChanged = true;
|
||||
}
|
||||
|
||||
if (fileChanged) {
|
||||
fs.writeFile(file, data, 'utf8', (err) => {
|
||||
if (err) return console.log(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user