Merge pull request #913 from Pax1601/912-implement-build-scripts-for-reactvite

912 implement build scripts for reactvite
This commit is contained in:
Pax1601 2024-07-26 11:17:11 +02:00 committed by GitHub
commit b993786301
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 88 additions and 438 deletions

3
.gitignore vendored
View File

@ -40,3 +40,6 @@ frontend/website/plugins/controltips/index.js
*.pyc
/scripts/**/*.jpg
manager/manager.log
/frontend/server/public/assets
/frontend/server/public/vite
/frontend/server/build

View File

@ -61,7 +61,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
FILEVERSION 2,0,0,0
PRODUCTVERSION 1,0,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DCS Olympus"
VALUE "FileDescription", "DCS Olympus"
VALUE "FileVersion", "1.0.4.0"
VALUE "FileVersion", "2.0.0.0"
VALUE "InternalName", "core.dll"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "core.dll"
VALUE "ProductName", "DCS Olympus"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "2.0.0.0"
END
END
BLOCK "VarFileInfo"

View File

@ -61,7 +61,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
FILEVERSION 2,0,0,0
PRODUCTVERSION 1,0,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DCS Olympus"
VALUE "FileDescription", "DCS Olympus"
VALUE "FileVersion", "1.0.4.0"
VALUE "FileVersion", "2.0.0.0"
VALUE "InternalName", "dcstools.dll"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "dcstools.dll"
VALUE "ProductName", "DCS Olympus"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "2.0.0.0"
END
END
BLOCK "VarFileInfo"

View File

@ -61,7 +61,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
FILEVERSION 2,0,0,0
PRODUCTVERSION 1,0,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DCS Olympus"
VALUE "FileDescription", "DCS Olympus"
VALUE "FileVersion", "1.0.4.0"
VALUE "FileVersion", "2.0.0.0"
VALUE "InternalName", "logger.dll"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "logger.dll"
VALUE "ProductName", "DCS Olympus"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "2.0.0.0"
END
END
BLOCK "VarFileInfo"

View File

@ -27,17 +27,18 @@ Logger* Logger::GetLogger()
void Logger::setDirectory(string newDirPath)
{
m_dirPath = newDirPath;
Clear();
}
void Logger::Clear()
{
lock_guard<mutex> guard(mutexLock);
try {
m_Logfile.open((m_dirPath + m_sFileName).c_str(), ios::out | std::ios::trunc);
m_Logfile.open((m_dirPath + m_sFileName).c_str(), ios::out | ios::trunc);
}
catch (...) {
std::filesystem::path m_dirPath = std::filesystem::temp_directory_path();
m_Logfile.open((m_dirPath.string() + m_sFileName).c_str(), ios::out | std::ios::trunc);
m_Logfile.open((m_dirPath.string() + m_sFileName).c_str(), ios::out | ios::trunc);
}
m_Logfile << "Creating a new log instance\n";
m_pThis->Close();

View File

@ -61,7 +61,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
FILEVERSION 2,0,0,0
PRODUCTVERSION 1,0,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DCS Olympus"
VALUE "FileDescription", "DCS Olympus"
VALUE "FileVersion", "1.0.4.0"
VALUE "FileVersion", "2.0.0.0"
VALUE "InternalName", "luatools.dll"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "luatools.dll"
VALUE "ProductName", "DCS Olympus"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "2.0.0.0"
END
END
BLOCK "VarFileInfo"

View File

@ -61,7 +61,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
FILEVERSION 2,0,0,0
PRODUCTVERSION 1,0,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DCS Olympus"
VALUE "FileDescription", "DCS Olympus"
VALUE "FileVersion", "1.0.4.0"
VALUE "FileVersion", "2.0.0.0"
VALUE "InternalName", "olympus.dll"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "olympus.dll"
VALUE "ProductName", "DCS Olympus"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "2.0.0.0"
END
END
BLOCK "VarFileInfo"

View File

@ -61,7 +61,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
FILEVERSION 2,0,0,0
PRODUCTVERSION 1,0,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "DCS Olympus"
VALUE "FileDescription", "DCS Olympus"
VALUE "FileVersion", "1.0.4.0"
VALUE "FileVersion", "2.0.0.0"
VALUE "InternalName", "utils.dll"
VALUE "LegalCopyright", "Copyright (C) 2023"
VALUE "OriginalFilename", "utils.dll"
VALUE "ProductName", "TODO: <Product name>"
VALUE "ProductVersion", "1.0.4.0"
VALUE "ProductVersion", "2.0.0.0"
END
END
BLOCK "VarFileInfo"

View File

@ -5,8 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite --port=8080",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"build-release": "vite build",
"preview": "vite preview"
},
"dependencies": {

View File

@ -5,4 +5,8 @@ import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
base: "/vite",
build: {
outDir: '../server/public/vite'
}
});

View File

@ -11,9 +11,21 @@
"skipFiles": [
"<node_internals>/**"
],
"args": ["--config", "${input:enterDir}/Config/olympus.json"],
"program": "./build/www.js",
"preLaunchTask": "build"
"runtimeExecutable": "nodemon",
"runtimeArgs": [
"--watch",
"src/**/*.ts",
"--exec",
"node",
"--inspect",
"-r",
"ts-node/register",
"src/www.ts",
"-c",
"${input:enterDir}/Config/olympus.json",
"--vite"
],
"restart": true
},
{
"type": "node",
@ -33,7 +45,8 @@
"ts-node/register",
"src/www.ts",
"-c",
"${input:enterDir}/Config/olympus.json"
"${input:enterDir}/Config/olympus.json",
"--vite"
],
"restart": true,
"preLaunchTask": "demo-server"

View File

@ -27,7 +27,7 @@ function createWindow() {
}
app.whenReady().then(() => {
const server = spawn('node', [path.join('.', 'bin', 'www'), "--config", args["config"]]);
const server = spawn('node', [path.join('.', 'build', 'www.js'), "--config", args["config"]]);
server.stdout.on('data', (data) => {
console.log(`${data}`);

View File

@ -4,15 +4,16 @@
"version": "{{OLYMPUS_VERSION_NUMBER}}",
"scripts": {
"build-release": "call ./scripts/build-release.bat",
"server": "node ./bin/www",
"server": "node ./build/www.js",
"client": "electron .",
"debug": "nodemon --watch src/**/*.ts --exec ts-node src/www.ts"
"tsc": "tsc"
},
"private": true,
"dependencies": {
"appjs": "^0.0.20",
"appjs-win32": "^0.0.19",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"debug": "~2.6.9",
"ejs": "^3.1.8",
"electron": "^28.0.0",
@ -31,7 +32,6 @@
"yargs": "^17.7.2"
},
"devDependencies": {
"cors": "^2.8.5",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
}

View File

@ -1,6 +0,0 @@
{
"name": "Control Tip Plugin",
"version": "0.0.1",
"description": "This plugin shows useful control tips on the right side of the screen. The tips change dynamically depending on what the user does",
"author": "Peekaboo"
}

View File

@ -1,33 +0,0 @@
#control-tips-panel {
align-self: center;
display: flex;
flex-flow: column wrap;
font-size: 13px;
justify-self: flex-end;
position: absolute;
right: 10px;
row-gap: 20px;
text-align: right;
z-index: 999;
}
#control-tips-panel>* {
align-items: center;
align-self: end;
background-color: var(--background-steel);
border-radius: var(--border-radius-md);
color: white;
column-gap: 8px;
display: flex;
justify-items: right;
opacity: .9;
padding: 5px;
width: fit-content;
}
#control-tips-panel>*>.key {
background-color: var(--background-grey);
border-radius: var(--border-radius-sm);
color: white;
padding: 1px 4px;
}

File diff suppressed because one or more lines are too long

View File

@ -1,6 +0,0 @@
{
"name": "Database Manager",
"version": "0.0.1",
"description": "This plugin allows to edit the unit databases",
"author": "DCSOlympus team"
}

View File

@ -1,295 +0,0 @@
#database-manager-panel {
flex-direction: column;
display: flex;
width: 80%;
height: 80%;
padding: 10px;
border-radius: 5px;
background-color: var(--background-steel) !important;
z-index: 9999999;
}
@media (min-width: 1200px) {
.dm-container {
flex-direction: row;
}
}
@media (max-width: 1200px) {
.dm-container {
flex-direction: column;
overflow-y: auto;
}
}
#database-manager-panel * {
font-size: 13;
font-family: 'Open Sans', sans-serif !important;
user-select: none;
}
#database-manager-panel>div:first-child {
display: flex;
align-items: center;
}
#database-manager-panel>div:last-child {
display: flex;
column-gap: 5px;
align-items: center;
justify-content: end;
justify-items: end;
margin-top: 5px;
}
#database-manager-panel>div:last-child>button {
border: 1px solid white;
}
.dm-container {
background-color: var(--background-grey);
border: 2px solid #777777;
position: relative;
display: flex;
width: 100%;
padding: 5px;
height: calc(100% - 64px - 5px);
border-radius: 0px 5px 5px 5px;
}
.dm-content-container {
position: relative;
margin: 10px;
display: flex;
flex-direction: column;
row-gap: 5px;
max-height: 100%;
padding: 10px;
}
@media (min-width: 1200px) {
.dm-content-container {
height: calc(100% - 20px);
}
.dm-content-container:nth-of-type(1) {
width: 400px;
}
.dm-content-container:nth-of-type(2) {
width: 500px;
}
.dm-content-container:nth-of-type(3) {
flex: 1;
}
}
@media (max-width: 1200px) {
.dm-content-container {
width: calc(100% - 20px);
}
.dm-content-container:nth-of-type(1) {
height: 30%;
}
.dm-content-container:nth-of-type(2) {
height: 50%;
}
.dm-content-container:nth-of-type(3) {
flex: 1;
}
}
.dm-content-container>label {
font-size: 18px !important;
font-weight: bold;
}
.dm-scroll-container {
display: flex;
flex-direction: column;
overflow-y: scroll;
max-height: 100%;
color: black;
font-weight: bold;
}
#database-manager-panel input {
font-weight: bold;
}
.dm-scroll-container>div:nth-child(even) {
background-color: gainsboro;
}
.dm-scroll-container>div:nth-child(odd) {
background-color: white;
}
.dm-scroll-container>div *:nth-child(1) {
height: 100%;
width: calc(100% - 25px);
padding: 2px;
word-wrap: break-word;
}
.dm-scroll-container>div *:nth-child(1):hover {
background-color: var(--accent-dark-blue);
color: white;
cursor: pointer;
}
.blueprint-selected {
background-color: var(--accent-light-blue) !important;
color: white;
}
.dm-scroll-container>div {
display: flex;
align-items: center;
justify-content: space-between;
}
.dm-scroll-container>div>div {
display: flex;
align-items: center;
justify-content: space-between;
}
.dm-scroll-container>div>button {
height: 20px;
width: 20px;
padding: 0px;
}
.dm-scroll-container>div>div>div:nth-child(1) {
width: fit-content;
}
.dm-scroll-container>div>div>div:nth-child(2) {
overflow: hidden;
text-wrap: nowrap;
text-overflow: ellipsis;
font-weight: normal;
}
.input-row {
width: 100%;
display: flex;
flex-direction: row;
}
@media (max-width: 1200px) {
.dm-content-container label {
width: 100%;
}
.input-row {
width: 50%;
}
}
.input-row>dt {
width: 250px;
}
.input-row>dd {
width: 100%;
text-align: right;
}
.input-row>dd>* {
width: 100%;
font-weight: bold;
}
.input-row>dd>*[type="checkbox"] {
width: 20px;
font-weight: bold;
}
.dm-loadout-container {
max-height: 100%;
max-width: 500px;
width: 100%;
}
.dm-items-container {
max-height: 100%;
height: fit-content;
}
.dm-items-container>div {
display: flex;
align-items: center;
column-gap: 2px;
}
.dm-items-container>div>label {
width: 80px !important;
}
.dm-items-container div>input:nth-of-type(1) {
flex: 1;
font-weight: bold;
}
.dm-items-container div>input:nth-of-type(2) {
width: 40px;
font-weight: bold;
}
.dm-new-element-input {
display: flex;
flex-direction: row;
column-gap: 2px;
width: 100%;
align-items: center;
}
.dm-new-element-input>input {
width: 100%;
}
.dm-new-element-input>button {
width: 60px;
}
.dm-new-item-input {
display: flex;
justify-content: end;
}
.dm-new-item-input>button {
width: 60px;
}
.tab-button {
transform: translateY(+3px);
background-color: var(--background-steel);
border-radius: 0;
border-bottom: 2px solid transparent !important;
border-top: 2px solid #777777 !important;
border-left: 2px solid #777777 !important;
border-right: 0px solid #777777 !important;
}
.tab-button.selected {
background-color: var(--background-grey);
z-index: 10;
}
.tab-button:first-of-type {
border-top-left-radius: 5px;
}
.tab-button:last-of-type {
border-top-right-radius: 5px;
border-right: 2px solid #777777 !important;
}
#database-manager-panel button :not(.dm-scroll-container>div) {
border: 1px solid white;
}

View File

@ -1,10 +1,8 @@
call .\scripts\copy.bat
call npm run tsc
echo D|xcopy /Y /S /E .\bin ..\..\build\frontend\bin
echo D|xcopy /Y /S /E .\public ..\..\build\frontend\public
echo D|xcopy /Y /S /E .\routes ..\..\build\frontend\routes
echo D|xcopy /Y /S /E .\views ..\..\build\frontend\views
echo D|xcopy /Y /S /E .\views ..\..\build\frontend\cert
echo D|xcopy /Y /S /E .\build ..\..\build\frontend\build
echo F|xcopy /Y .\app.js ..\..\build\frontend\app.js
echo F|xcopy /Y .\client.js ..\..\build\frontend\client.js

View File

@ -1,2 +0,0 @@
echo F|xcopy /Y ..\website\node_modules\leaflet\dist\leaflet.css .\public\stylesheets\leaflet\leaflet.css
echo F|xcopy /Y ..\website\node_modules\leaflet-gesture-handling\dist\leaflet-gesture-handling.css .\public\stylesheets\leaflet\leaflet-gesture-handling.css

View File

@ -1,3 +1,2 @@
call .\scripts\copy.bat
call .\scripts\create-mock-dcs.bat
nodemon --watch src\demo\**\*.ts --exec node --inspect -r ts-node\register .\src\demo\www.ts -c %1

View File

@ -9,7 +9,7 @@ import cors = require("cors");
/* Load the proxy middleware plugin */
import httpProxyMiddleware = require("http-proxy-middleware");
module.exports = function (configLocation) {
module.exports = function (configLocation, viteProxy) {
/* Config specific routers */
const elevationRouter = require("./routes/api/elevation")(configLocation);
const resourcesRouter = require("./routes/resources")(configLocation);
@ -26,8 +26,6 @@ module.exports = function (configLocation) {
"databases"
)
);
const indexRouter = require("./routes/index");
const pluginsRouter = require("./routes/plugins");
/* Load the config and create the express app */
let config = {};
@ -57,22 +55,33 @@ module.exports = function (configLocation) {
changeOrigin: true,
})
);
app.use(
"/vite",
httpProxyMiddleware.createProxyMiddleware({ target: `http://localhost:8080/`, ws: true })
);
if (viteProxy) {
app.use(
"/vite",
httpProxyMiddleware.createProxyMiddleware({
target: `http://localhost:8080/`,
ws: true,
})
);
}
app.use(bodyParser.json({ limit: "50mb" }));
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
app.use(express.static(path.join(__dirname, "..", "public")));
app.use(cors());
/* Apply routers */
app.use("/", indexRouter);
app.use("/api/airbases", airbasesRouter);
app.use("/api/elevation", elevationRouter);
app.use("/api/databases", databasesRouter);
app.use("/plugins", pluginsRouter);
app.use("/resources", resourcesRouter);
/* Set default index */
if (!viteProxy) {
app.get("/", function (req, res) {
res.sendfile(path.join(__dirname, "..", "public", "vite", "index.html"));
});
}
return app;
};

View File

@ -1,9 +0,0 @@
import express = require('express');
const router = express.Router();
/* GET home page. */
router.get('/', function (req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;

View File

@ -1,21 +0,0 @@
import express = require('express');
import fs = require('fs');
import path = require('path');
const pluginsDirectory = "./public/plugins"
const router = express.Router();
function listDirectories(source) {
const directories = fs.readdirSync(source, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
return directories;
}
router.get('/list', function (req, res) {
var directories = listDirectories(pluginsDirectory);
res.send(directories.filter(directory => fs.existsSync(path.join(pluginsDirectory, directory))));
});
module.exports = router;

View File

@ -2,11 +2,15 @@ import yargs = require("yargs");
import fs = require("fs");
import http = require("http");
/* Define configuration parameter */
/* Define configuration parameters */
yargs
.alias("c", "config")
.describe("c", "olympus.json config location")
.string("rp");
.string("c");
yargs
.alias("v", "vite")
.describe("v", "proxy requests to vite server for development")
.boolean("v");
const args = yargs.argv;
/* Startup print */
@ -20,7 +24,7 @@ if (fs.existsSync(args["config"])) {
httpPort = json["frontend"]["port"];
/* Load the dependencies. The app is loaded providing the configuration file location */
const app = require("./app")(args["config"]);
const app = require("./app")(args["config"], args["vite"]);
/* Normalize port */
const port = normalizePort(httpPort);

View File

@ -2,8 +2,7 @@
"compilerOptions": {
"outDir": "./build",
"allowJs": true,
"target": "es5",
"sourceMap": true
"target": "es5"
},
"include": [
"./src/**/*"

View File

@ -7,21 +7,9 @@ cd ..
cd frontend
cd website
call npm install
call npm run emit-declarations
call npm run build-release
cd plugins\controltips
cd react
call npm install
call npm run build-release
cd ..\..
cd plugins\databasemanager
call npm install
call npm run build-release
cd ..\..
cd ..
cd server

View File

@ -5,6 +5,7 @@ local _prevLuaExportStop = LuaExportStop
local server = nil
local port = 3003
local headers = "Access-Control-Allow-Private-Network: true\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Methods: *\r\nAccess-Control-Allow-Headers: *\r\nAccess-Control-Max-Age: 86400\r\nVary: Accept-Encoding, Origin\r\n\r\n"
local positionToSet = nil
function startTCPServer()
log.write('OLYMPUSCAMERACONTROL.EXPORT.LUA', log.INFO, 'Starting TCP Server')
@ -35,8 +36,6 @@ function receiveTCP()
local acc = ""
local data = ""
log.write('OLYMPUSCAMERACONTROL.EXPORT.LUA', log.INFO, 'CONNECTION')
-- Start receiving data, accumulate it in acc
while data ~= nil do
@ -139,7 +138,9 @@ function setCameraPosition(position)
z = {x = 0, y = 0, z = 1},
p = {x = point.x, y = altitude, z = point.z}
}
LoSetCameraPosition(pos)
-- Store the value in a variable so that it can be set at the next frame
positionToSet = pos
return '{"northRotation": ' .. rotation .. '}'
end
@ -160,6 +161,11 @@ LuaExportStart = function()
end
LuaExportBeforeNextFrame = function()
if positionToSet ~= nil then
LoSetCameraPosition(positionToSet)
positionToSet = nil
end
receiveTCP()
-- call original